In [6]:
try:
from xmlrpc import client
except ImportError:
import xmlrpclib as client
import matplotlib.pyplot as plt
%matplotlib inline
In [7]:
PY2_CLASSIFIERS = [
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.4",
"Programming Language :: Python :: 2.3",
]
PY3_CLASSIFIERS = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.0",
"Programming Language :: Python :: 3.1",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
]
In [8]:
pypi_client = client.ServerProxy('http://pypi.python.org/pypi')
# name[0] is package name
# name[1] is package version
py2_packages = {
name[0]
for classifier in PY2_CLASSIFIERS
for name in pypi_client.browse([classifier])
}
py3_packages = {
name[0]
for classifier in PY3_CLASSIFIERS
for name in pypi_client.browse([classifier])
}
In [9]:
labels = ['Py 2 only', 'Py 3 only', 'Py2 and 3']
total = len(py2_packages | py3_packages)
py2only = len(py2_packages - py3_packages)
py3only = len(py3_packages - py2_packages)
both = len(py2_packages & py3_packages)
plt.pie([py2only, py3only, both], autopct='%1.1f%%',
labels=labels, shadow=True, startangle=90)
Out[9]:
In [9]: