Search pypi package filtering by processor architecture

I’m wondering how can I find a package on pypi with filtering by amd/arm processor architecture, let’s say I need to download the .whl file of the numpy package for windows amd64, how can I get a direct link to this .whl file? pip search is not filtered by processor architecture

>Solution :

let’s say I need to download the .whl file of the numpy package for windows amd64, how can I get a direct link to this .whl file?

I’d use the JSON metadata endpoint, e.g. https://pypi.org/pypi/numpy/json, so to print out all windows amd64 cpython 3.11 wheels for numpy:

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"])

This prints out e.g. (URLs redacted for brevity)

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.whl

The filename for wheels is well specified so you should be able to rely on that endswith.

Leave a Reply