【发布时间】:2023-02-13 16:48:46
【问题描述】:
我想知道如何通过 amd/arm 处理器架构在 pypi 上找到一个包,假设我需要为 windows amd64 下载 numpy 包的 .whl 文件,我如何获得这个 .whl 的直接链接文件? pip search 没有被处理器架构过滤
【问题讨论】:
我想知道如何通过 amd/arm 处理器架构在 pypi 上找到一个包,假设我需要为 windows amd64 下载 numpy 包的 .whl 文件,我如何获得这个 .whl 的直接链接文件? pip search 没有被处理器架构过滤
【问题讨论】:
假设我需要为 windows amd64 下载 numpy 包的 .whl 文件,我怎样才能获得这个 .whl 文件的直接链接?
我会使用 JSON 元数据端点,例如https://pypi.org/pypi/numpy/json,所以要为 numpy 打印出所有 windows amd64 cpython 3.11 wheels:
import httpx j = httpx.get("https://pypi.org/pypi/numpy/json").json() for version, releases in sorted(j["releases"].items(), reverse=True): for rel in releases: if rel["packagetype"] == "bdist_wheel" and rel["filename"].endswith("cp311-win_amd64.whl"): print(version, rel["url"])这打印出例如(为简洁起见,对 URL 进行了编辑)
1.24.2 https://files.pythonhosted.org/packages/17/57/82c3a9321...d5833/numpy-1.24.2-cp311-cp311-win_amd64.whl 1.24.1 https://files.pythonhosted.org/packages/73/39/f104eb30c...e2af9/numpy-1.24.1-cp311-cp311-win_amd64.whl 1.24.0 https://files.pythonhosted.org/packages/3f/b8/3c549c217...16be9/numpy-1.24.0-cp311-cp311-win_amd64.whl 1.23.5 https://files.pythonhosted.org/packages/19/0d/b8c34e4ba...74ea9/numpy-1.23.5-cp311-cp311-win_amd64.whl 1.23.4 https://files.pythonhosted.org/packages/eb/a6/a3217b371...3a799/numpy-1.23.4-cp311-cp311-win_amd64.whl 1.23.3 https://files.pythonhosted.org/packages/2e/bd/286dacf26...545d2/numpy-1.23.3-cp311-cp311-win_amd64.whl 1.23.2 https://files.pythonhosted.org/packages/f5/85/3b622959c...0a3f3/numpy-1.23.2-cp311-cp311-win_amd64.whlwheels 的文件名是well specified 所以你应该可以依赖那个
endswith。
【讨论】: