【发布时间】:2011-02-09 17:56:30
【问题描述】:
我很好奇是否有只支持 Python 3 的重要库,因为似乎许多支持它的库也恰好支持 Python 2。
【问题讨论】:
标签: python python-3.x
我很好奇是否有只支持 Python 3 的重要库,因为似乎许多支持它的库也恰好支持 Python 2。
【问题讨论】:
标签: python python-3.x
不,没有这样的索引,但您可以根据 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 接口可能有用:
【讨论】:
出现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()
【讨论】:
Python3-only packages: 2823 (of 14595)
在 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
【讨论】: