2013-12-22 22 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