是否有某个Py3k专用库的索引?

时间:2011-02-09 17:56:30

标签: python python-3.x

我很好奇是否有重要的库只支持Python 3,因为看起来许多支持它的库也恰好支持Python 2.

3 个答案:

答案 0 :(得分:5)

不,没有这样的索引,但您可以在PyPI上的分类器数据中创建一个。

您可以列出所有包含“Programming Language :: Python :: 3”或Programming Language :: Python :: 3.0“或”Programming Language :: Python 3.1“的软件包,但不包含Python 2分类器

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

可能XML接口很有用:

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

答案 1 :(得分:5)

它显示为there isn't,所以我写了这个(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()

答案 2 :(得分:2)

PyPI中有一个Programming Language :: Python :: 3 :: Only分类器,只有Python 3才能使用。但是,并非所有仅使用Python 3的软件包都配置了它。

您可以使用此分类器过滤PyPI网站中的包:https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3+%3A%3A+Only

相关问题