2

我有一个 Django Web 应用程序,它通过 Pip 从 requirements.txt 文件安装一些要求。

我最初编写我的部署脚本以在pip install -r requirements.txt每次部署时运行,因为我在我正在部署的提交中更改了 requirements.txt 文件。这并没有对性能造成太大影响(就部署时间而言),因为这些包都在 PyPI 上,而且 Pip 会进行某种智能缓存,并且不会每次都下载我已经拥有的包。

不过,最近,我转而使用一些 PyPI 上还没有的包——只是在 Github 上。我可以通过在我的 requirements.txt 中添加如下行来安装它们:

-e git+git://github.com/BowdoinOrient/django-storages-py3.git#egg=django-storages-py3
-e git+git://github.com/BowdoinOrient/topia.termextract.git#egg=topia.termextract

但这很慢 - Pip 似乎每次都检查 git 存储库,或者至少进行某种网络活动,无论该 Github 存储库最近是否已更新。

我想我可以通过指定我想要安装的确切提交来阻止 Pip 这样做,如下所示:

-e git+git://github.com/BowdoinOrient/django-storages-py3.git@83f18f5ccf39b5be230c6fc24d3b0b35c98277db#egg=django-storages-py3
-e git+git://github.com/BowdoinOrient/topia.termextract.git@2effd5f7274fb962292503d6d16938e68497059e#egg=topia.termextract

但是 Pip 总是会在这些线路上放慢速度并检查 Github 以获取某种附加信息,即使我已经在这些提交时安装了这些模块。

有什么方法可以加快 Pip 完成这些步骤的速度吗?还是我应该使用的比 Pip 更快的东西?我看着凝乳,但我不认为这是我需要的。

谢谢!

4

1 回答 1

4

Fixed my own problem: removing the -e (--editable) flag from VCS lines in the requirements.txt file keeps pip from cloning them if they already exist at the correct commit hash.

Documentation on pip's -e flag.

I also had the wrong egg name of one of the repositories as well, so watch out for that if you run across this problem too.

于 2014-11-16T05:49:51.150 回答