2013-12-22 84 views
4

我正在构建一个应用程序,它使用photologue和一些其他包作为依赖关系的photologue(例如,cmsplugin-photologue)。但是,我需要使用github上托管的photologue的修改版本。所有这些都将部署在Heroku上,这意味着依赖关系的安装完全是通过requirements.txt文件完成的。使用pip替换对自定义叉的依赖关系

原则上这很容易完成:我可以按照here所述将知识库添加到需求文件中,并将其安装。问题是原来的photologue也被安装了,并且结束了正在使用的那个。

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

回答

4

只需使用-U--upgrade选项,以取代原来的包在你的VENV与您的自定义版本:

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

然后在你的要求中.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 
0

This section of the documentation为旧版本的PIP表明,如果PIP发现多个定义为一个包(例如,经由--extra-index-url--find-links),最后的匹配将被使用。不幸的是,我在当前的文档中找不到这些信息,所以它可能已经改变。

也许这样的事情在你的要求的文件将工作:

... 
django-photologue 
... 

--find-links https://github.com/jdriscoll/django-photologue