How to download cross-platform wheels via pip?

2019-04-06 18:40发布

I'm accustomed to pre-downloading packages using Pip, then copying them over to a target machine for deployment. With the newly introduced Python Wheels, I'm forced to "pip ... --no-use-wheel", as some of the downloaded packages are platform specific (I'm developing on OSX and deploying to Debian) and will not install on the target machine. Is there a way to download Wheels for target platforms (or platform independent)?

2条回答
可以哭但决不认输i
2楼-- · 2019-04-06 19:25

The easiest way to achieve that is IMO to use a custom script.

You can access the whole of the PyPI index via the simple interface, if the package of interest offers one or more wheels, they will be listed at the same address + /<package-name>.

For example: if you were to install setuptools all wheels would be listed at: https://pypi.python.org/simple/setuptools/

In your script, remember to implement the recommended tag priority as specified by PEP-425. Essentially that boils down to download the most specific (as opposed to the most general) version of the package as this normally translate into performance advantages, with for example C extensions replacing pure python implementations of some algorithm.

查看更多
乱世女痞
3楼-- · 2019-04-06 19:34

The pip download command now has the --platform argument, which you can use to specify the desired platform:

pip download --platform=manylinux1_x86_64 --only-binary=:all: lxml
查看更多
登录 后发表回答