Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make pip download prefer to download source-distributions (not wheels)

Tags:

python

pip

This question explains how to make pip download and save packages. If I follow this formula, Pip will download wheel (.whl) files if available.

(venv) [user@host glances]$ pip download -d wheelhouse -r build_requirements.txt
Collecting wheel (from -r build_requirements.txt (line 1))
  File was already downloaded /usr_data/tmp/glances/wheelhouse/wheel-0.29.0-py2.py3-none-any.whl
Collecting pex (from -r build_requirements.txt (line 2))
  File was already downloaded /usr_data/tmp/glances/wheelhouse/pex-1.1.18-py2.py3-none-any.whl
Collecting requests (from -r build_requirements.txt (line 3))
  File was already downloaded /usr_data/tmp/glances/wheelhouse/requests-2.12.4-py2.py3-none-any.whl
Collecting pip (from -r build_requirements.txt (line 4))
  File was already downloaded /usr_data/tmp/glances/wheelhouse/pip-9.0.1-py2.py3-none-any.whl
Collecting setuptools (from -r build_requirements.txt (line 5))
  File was already downloaded /usr_data/tmp/glances/wheelhouse/setuptools-32.3.1-py2.py3-none-any.whl
Successfully downloaded wheel pex requests pip setuptools

Every single file that it downloaded was a Wheel - but what if I want to get a different kind of file?

I actually want to download the sdist (.tar.gz) files in preference to .whl files? Is there a way to tell Pip what kinds of files I actually want it to get? So instead of getting a directory full of wheels I might want a bunch of tar.gz files.

like image 480
Salim Fadhley Avatar asked Jan 06 '17 11:01

Salim Fadhley


People also ask

What is the difference between pip install and pip download?

Overview. pip download does the same resolution and downloading as pip install , but instead of installing the dependencies, it collects the downloaded distributions into the directory provided (defaulting to the current directory).

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.

How does pip decide which version to install?

Once pip has a list of compatible distributions, it sorts them by version, chooses the most recent version, and then chooses the "best" distribution for that version. It prefers binary wheels if there are any, and if they are multiple it chooses the one most specific to the install environment.


1 Answers

use pip download --no-binary=:all: -r requirements.txt

According to the pip documentation:

--no-binary:

Do not use binary packages. Can be supplied multiple times, and each time adds to the existing value. Accepts either :all: to disable all binary packages, :none: to empty the set, or one or more package names with commas between them. Note that some packages are tricky to compile and may fail to install when this option is used on them.

It worked for me!

like image 125
pushpam anand Avatar answered Nov 15 '22 15:11

pushpam anand