I would do pretty much what @phd suggested in the comments.
Instead of trying to install directly on your production machine, you can download and build everything on your build machine, then move the ready files over. Here’s how:
On your build machine, use pip to download the package and all its dependencies:
python -m pip download example-package -d ./wheels
That grabs wheels and source archives into ./wheels
.
If you see any .tar.gz
files, build them into wheels so you have everything precompiled:
python -m pip wheel --no-deps --wheel-dir=./wheels ./wheels/*.tar.gz
Copy the entire wheels
folder to your production machine.
On your production machine, install from those local files without touching PyPI:
python -m pip install --no-index --find-links=./wheels example-package
This way, your production machine unpacks prebuilt wheels—no compilation needed.