Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download cross-platform wheels via pip?

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)?

like image 772
mixman Avatar asked Jun 07 '14 12:06

mixman


People also ask

How do I download pip files?

pip can be downloaded and installed using command-line by going through the following steps: Download the get-pip.py file and store it in the same directory as python is installed. Change the current path of the directory in the command line to the path of the directory where the above file exists.

Does pip download download dependencies?

The pip download command can be used to download packages and their dependencies to the current directory (by default), or else to a specified location without installing them.

What is pip install wheel?

If you've installed a Python package using pip , then chances are that a wheel has made the installation faster and more efficient. Wheels are a component of the Python ecosystem that helps to make package installs just work. They allow for faster installations and more stability in the package distribution process.


2 Answers

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
  • the --platform=manylinux1_x86_64 option indicates that you want wheels for this specific platform. manylinux1_x86_64 means roughly "compatible with most distributions and with an intel CPU architecture". This answer links to some PEPs that describe which platforms exist and what OS/CPU they are compatible with.
  • the --only-binary=:all: forces the use of binary distribution packages (ie. wheels, as opposed to sdist "source distribution packages") for ":all:" the things that will be installed in this command. Instead of :all:, one can pass a comma-separated list of specific distribution packages; see pip install --help for more info.

Note: I use the term "distribution package" to avoid confusion with the other kind of "package" (the ones one can import in a python script).

like image 182
sitaktif Avatar answered Oct 10 '22 23:10

sitaktif


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.

like image 39
mac Avatar answered Oct 10 '22 23:10

mac