我正在构建一个应用程序,它使用 photologue
和其他一些将 photologue
作为依赖项的包(例如,cmsplugin-photologue
) .但是,我需要使用 github 上托管的 photologue
的修改版本。然后所有这些都将部署在 Heroku 上,这意味着依赖项的安装仅通过 requirements.txt
文件完成。
原则上这很容易完成:我可以按照 here 所述将存储库添加到需求文件中。它将被安装。问题是原来的 photologue
也被安装了,最终被使用了。
所以一般的问题是:使用 pip
,我如何用我自己的应用程序版本替换依赖于多个应用程序的应用程序?
最佳答案
只需使用 -U
或 --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
关于python - 使用 pip 将依赖项替换为自定义 fork ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20731822/