开发者

Is there somewhere an index of Py3k-only libraries?

I'm curious if there are important libraries that support only Python 3, since it appears that many libraries that do开发者_Python百科 support it, also happen to support Python 2.


No, there is no such index, but you could create one from the classifier data on PyPI.

You could make a list of all packages that has "Programming Language :: Python :: 3" or Programming Language :: Python :: 3.0" or "Programming Language :: Python 3.1", but none of the Python 2 classifiers.

http://pypi.python.org/pypi?:action=browse&c=214

Possibly the XML interface can be useful:

http://wiki.python.org/moin/PyPiXmlRpc


It appears there isn't, so I wrote this (with some help):

#!/usr/bin/env python3

import xmlrpc.client

# PyPI classifiers for all Python 3 versions
PY3 = [
    "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",
]

# PyPI classifiers for all Python 2 versions
PY2 = [
    "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",
]

def main():
    client = xmlrpc.client.ServerProxy('http://pypi.python.org/pypi')
    # name[0] is package name
    # name[1] is package version
    py3names = [
        name[0] for classifier in PY3 for name in client.browse([classifier])
    ]
    py2names = [
        name[0] for classifier in PY2 for name in client.browse([classifier])
    ]
    py3only = [name for name in py3names if name not in py2names]
    template = "Python3-only packages: {} (of {})"
    print(template.format(len(py3only), len(set(py2names + py3names))))

if __name__ == "__main__":
    main()


There is a Programming Language :: Python :: 3 :: Only classifier in PyPI that Python 3 only packages should be using. However, not all Python 3 only packages have been configured with it.

You can use this classifier to filter the packages in the PyPI website: https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3+%3A%3A+Only

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜