7

我正在构建一个应用程序,它使用photologue和一些其他包photologue作为依赖项(例如,cmsplugin-photologue)。但是,我需要使用photologuegithub 上托管的修改版本。然后,所有这些都将部署在 Heroku 上,这意味着依赖项的安装仅通过requirements.txt文件完成。

原则上,这很容易完成:我可以按照此处所述将存储库添加到需求文件中,它将被安装。问题是原件photologue也已安装并最终被使用。

所以一般的问题是:使用pip,我如何用我自己的应用程序版本替换依赖于多个应用程序的应用程序?

4

2 回答 2

5

只需使用-Uor--upgrade选项将 venv 中的原始包替换为您的自定义版本:

cd myapp && venv/bin/pip install -U git+https://github.com/jcomeauictx/django-crispy-forms.git

然后在您的 requirements.txt 中替换该行

django-crispy-forms==1.4.0

git+https://github.com/jcomeauictx/django-crispy-forms.git

当您推送到您的 heroku 实例时,您应该会看到如下内容:

-----> Deleting 1 files matching .slugignore patterns.
-----> Python app detected
-----> Uninstalling stale dependencies
       Uninstalling django-crispy-forms-1.4.0:
         Successfully uninstalled django-crispy-forms-1.4.0
-----> Installing dependencies with pip
       Collecting git+https://github.com/jcomeauictx/django-crispy-forms.git (from -r requirements.txt (line 6))
         Cloning https://github.com/jcomeauictx/django-crispy-forms.git to /tmp/pip-AlSPnZ-build
       Installing collected packages: django-crispy-forms
         Running setup.py install for django-crispy-forms
       Successfully installed django-crispy-forms-1.5.0
于 2015-03-18T01:35:40.047 回答
0

旧版本 PIP文档的这一部分建议,如果 PIP 找到一个包的多个定义(例如 via--extra-index-url--find-links),则将使用最后一个匹配项。不幸的是,我在当前文档中找不到此信息,因此它可能已更改。

也许你的需求文件中这样的东西会起作用:

...
django-photologue
...

--find-links https://github.com/jdriscoll/django-photologue
于 2013-12-22T23:50:07.383 回答