Last active
November 30, 2021 22:58
-
-
Save henryiii/4f0715e64df7cf267d2d2490b5facee9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run inside https://github.com/mayeut/manylinux-timeline | |
# | |
# Example nox file for those too lazy to set up a venv: | |
# | |
# import nox | |
# | |
# @nox.session(reuse_venv=True) | |
# def run(session): | |
# session.install("hist[plot]", "pandas") | |
# session.run("python", "make_hist.py") | |
from hist import Hist | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from pathlib import Path | |
import numpy as np | |
def ver_to_int(version): | |
major, minor = version.split(".") | |
minor = minor.split("b")[0].split("-")[0] | |
return (int(major) % 2000) * 100 + int(minor) | |
data = [] | |
for file_path in Path("consumer_data/2021/10").glob("*.csv"): | |
data.append( | |
pd.read_csv( | |
file_path, | |
converters={ | |
"python_version": str, | |
"pip_version": ver_to_int, | |
"glibc_version": ver_to_int, | |
}, | |
) | |
) | |
df = pd.concat(data).reset_index() | |
glib_ml = pd.cut( | |
df["glibc_version"], | |
bins=(0, 200, 205, 212, 217, 1000), | |
labels=("0", "1", "2010", "2014", "2_24"), | |
) | |
pip_ml = pd.cut( | |
df["pip_version"], | |
bins=(0, 801, 1900, 1903, 2003, 3000), | |
labels=("0", "1", "2010", "2014", "2_24"), | |
) | |
codes = np.min([glib_ml.cat.codes, pip_ml.cat.codes], axis=0) | |
all_ml = pd.Series(codes, dtype="category") | |
all_ml.cat.categories = ("0", "1", "2010", "2014", "2_24") | |
df["policy"] = all_ml | |
df["max_policy"] = glib_ml | |
h = Hist.from_columns( | |
df, | |
("cpu", "python_version", "pip_version", "policy", "max_policy"), | |
weight="num_downloads", | |
) | |
fig, axs = plt.subplots(2, 3, figsize=(12, 8)) | |
for i, py in enumerate(["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"]): | |
ax = axs.flatten()[i] | |
ph = h.project("python_version", "pip_version")[py, :] | |
ph.plot_pie(ax=ax, normalize=True, autopct="%1.0f%%", pctdistance=0.8) | |
ax.set_title(f"Python {py} {int(ph.sum()) // 1000000:,} M") | |
fig.suptitle("October 2021 all manylinux") | |
plt.tight_layout() | |
plt.savefig("pip_versions.png") | |
fig, axs = plt.subplots(2, 3, figsize=(12, 8)) | |
for i, py in enumerate(["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"]): | |
ax = axs.flatten()[i] | |
ph = h.project("python_version", "policy")[py, :] | |
ph.plot_pie(ax=ax, normalize=True, autopct="%1.0f%%", pctdistance=0.8) | |
ax.set_title(f"Python {py} {int(ph.sum()) // 1000000:,} M") | |
fig.suptitle("October 2021 all manylinux") | |
plt.savefig("manylinux_versions.png") | |
fig, axs = plt.subplots(2, 3, figsize=(12, 8)) | |
for i, py in enumerate(["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"]): | |
ax = axs.flatten()[i] | |
ph = h.project("python_version", "max_policy")[py, :] | |
ph.plot_pie(ax=ax, normalize=True, autopct="%1.0f%%", pctdistance=0.8) | |
ax.set_title(f"Python {py} {int(ph.sum()) // 1000000:,} M") | |
fig.suptitle("October 2021 max supported manylinux") | |
plt.savefig("manylinux_max.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment