让pip下载更喜欢下载源代码分发(不是轮子)

时间:2017-01-06 11:06:25

标签: python pip

这个问题explains如何制作pip下载和保存包。如果我遵循这个公式,Pip将下载wheel(.whl)文件(如果可用)。

(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

它下载的每个文件都是一个Wheel - 但如果我想获得另一种文件怎么办?

我实际上想要下载sdist(.tar.gz)文件而不是.whl文件?有没有办法告诉Pip我真正希望它得到什么类型的文件?因此,我没有得到一个充满轮子的目录,而是想要一堆tar.gz文件。

2 个答案:

答案 0 :(得分:7)

根据pip install -h

  

- 禁用轮在搜索索引和查找链接位置时,不要查找并更喜欢轮存档。弃用了--no-binary。

  

- no-binary不要使用二进制包。可以多次提供,每次都会增加现有值。接受:all:禁用所有二进制包,:none:清空集合,或者一个或多个包

如果您的版本太旧,则可能需要使用pip install -U pip升级pip。

答案 1 :(得分:1)

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

根据pip文档:

-无二进制:

  

请勿使用二进制软件包。可提供多次,每次   时间增加了现有价值。接受:all:禁用所有   二进制软件包,:none:清空集合,或者一个或多个软件包名称   它们之间用逗号隔开。请注意,有些软件包很难   编译并在它们上使用此选项时可能无法安装。

对我有用!