Reputation: 51
I'm trying to figure out what's the difference between these two python commands:
pip wheel --wheel-dir=some_dir -r requirement.txt
and
pip download -d some_dir -r requirement.txt
At first I thought "pip download" by default downloads the requirements from pypi.org index in 'whl' format and places them in some_dir, while "pip wheel" 'extracts' and builds the requirements, still in 'whl' format, from the current python environment and places them in some_dir. But apparently what both of them do is downloading the dependencies from the pypi.org index (by default). In fact, I tried the "pip wheel" command on an (virtual)python environment which didn't have installed any of the 'requirements.txt', yet still all of the 'whl's were found in 'some_dir'. The official documentation doesn't state this very clearly, though.
Hence my questions:
Thanks in advance!
Upvotes: 4
Views: 8953
Reputation: 724
I'm also curious about this question and the official doc is really ambiguous.
First, with my experiment, the two commands you provided will produce the same output, and the process is quite similar.
But after I read the official doc carefully, I have found that some options of these two commands are different.
for pip download
, this command is focused on downloading packages from somewhere, even it will also try to built it, but it will fallback to download the source packge if it can't built it. There are some options for you to filter the packages you want to download, even if the packages are not compatible with your current environment. Like --platform
, --python-version
, --implementation
, so you can download packages for whatever interpreter you want.
for pip wheel
, this command is focused on building a wheel for a package and its dependencies. It provides the option --build-option
to let you customize the build process. So, with this command you can only download the packages which are compatible with your current interpreter and platform.
In my opinion, pip wheel
is more like pip install
than pip download
, because it can only "download" the packages with current interpreter.
Now for your questions:
Are then the two commands equivalent? (In this case this would look like replication of instructions, not really a good design principle uncle Guido!)
Answer: For packages compatible with the current interpreter, yes, they are almost equivalent, except if you want certain build options.
How can I achieve my goal of obtaining the whls required out of my python environment and ignoring any internet 'index's?
Answer: Both commands can download from a local index or a local directory, but if you want packages for other platforms, you'll need pip download
. In your situation, you may create your own index or a directory holding all packages you need, and install from there every time.
Expect more precise answers.
Upvotes: 4