如何确定Python中特定包名可用的Python包数量?

rqdpfwrv  于 12个月前  发布在  Python
关注(0)|答案(1)|浏览(121)

Python包在与不同Python版本和平台的兼容性方面有所不同。例如,在PyPI上的“cffi”等于1.16.0版本包的情况下,您可以找到大约51个针对各种Python版本和平台(如Windows,macOS和Linux)量身定制的不同包。另一方面,像'coloredlogs' equals 15.0.1版本这样的软件包提供了一个可以在所有平台和不同Python版本上工作的单一软件包。
有没有一种方法可以确定特定版本的任何Python包的变体数量?

mm9b1k5b

mm9b1k5b1#

你可以在PyPI JSON API中找到这些。
发行版coloredlogs==15.0.1只提供了2个文件,一个sdist和一个universal wheel:

>>> resp = urllib3.request("GET", "https://pypi.org/pypi/coloredlogs/15.0.1/json")
>>> data = resp.json()
>>> len(data["urls"])
2
>>> for dist in data["urls"]:
...     print(dist["filename"])
... 
coloredlogs-15.0.1-py2.py3-none-any.whl
coloredlogs-15.0.1.tar.gz

字符串
这个包是pure Python源代码,不提供任何编译的扩展模块,所以一个通用的wheel就足够了。
但例如,对于问题中提到的cffi 1.16.0,有许多轮子可用,使用不同的platform compatibility tags构建:

>>> import urllib3
>>> resp = urllib3.request("GET", "https://pypi.org/pypi/cffi/1.16.0/json")
>>> data = resp.json()
>>> len(data["urls"])
52


实际的文件名:

>>> for dist in data["urls"]:
...     print(dist["filename"])
... 
cffi-1.16.0-cp310-cp310-macosx_10_9_x86_64.whl
cffi-1.16.0-cp310-cp310-macosx_11_0_arm64.whl
cffi-1.16.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
cffi-1.16.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
cffi-1.16.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
cffi-1.16.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl
cffi-1.16.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cffi-1.16.0-cp310-cp310-musllinux_1_1_i686.whl
cffi-1.16.0-cp310-cp310-musllinux_1_1_x86_64.whl
cffi-1.16.0-cp310-cp310-win32.whl
cffi-1.16.0-cp310-cp310-win_amd64.whl
cffi-1.16.0-cp311-cp311-macosx_10_9_x86_64.whl
cffi-1.16.0-cp311-cp311-macosx_11_0_arm64.whl
cffi-1.16.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
cffi-1.16.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
cffi-1.16.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
cffi-1.16.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl
cffi-1.16.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cffi-1.16.0-cp311-cp311-musllinux_1_1_i686.whl
cffi-1.16.0-cp311-cp311-musllinux_1_1_x86_64.whl
cffi-1.16.0-cp311-cp311-win32.whl
cffi-1.16.0-cp311-cp311-win_amd64.whl
cffi-1.16.0-cp312-cp312-macosx_10_9_x86_64.whl
cffi-1.16.0-cp312-cp312-macosx_11_0_arm64.whl
cffi-1.16.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
cffi-1.16.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
cffi-1.16.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
cffi-1.16.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl
cffi-1.16.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cffi-1.16.0-cp312-cp312-musllinux_1_1_x86_64.whl
cffi-1.16.0-cp312-cp312-win32.whl
cffi-1.16.0-cp312-cp312-win_amd64.whl
cffi-1.16.0-cp38-cp38-macosx_10_9_x86_64.whl
cffi-1.16.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
cffi-1.16.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
cffi-1.16.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
cffi-1.16.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl
cffi-1.16.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cffi-1.16.0-cp38-cp38-win32.whl
cffi-1.16.0-cp38-cp38-win_amd64.whl
cffi-1.16.0-cp39-cp39-macosx_10_9_x86_64.whl
cffi-1.16.0-cp39-cp39-macosx_11_0_arm64.whl
cffi-1.16.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
cffi-1.16.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
cffi-1.16.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
cffi-1.16.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl
cffi-1.16.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cffi-1.16.0-cp39-cp39-musllinux_1_1_i686.whl
cffi-1.16.0-cp39-cp39-musllinux_1_1_x86_64.whl
cffi-1.16.0-cp39-cp39-win32.whl
cffi-1.16.0-cp39-cp39-win_amd64.whl
cffi-1.16.0.tar.gz

相关问题