python - 使用 pip 将依赖项替换为自定义 fork

标签 python git heroku pip requirements.txt

我正在构建一个应用程序,它使用 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/

相关文章:

python - 融化后从 pandas 数据框中提取行作为列

ruby-on-rails - Heroku 部署错误 H10(应用程序崩溃)

Heroku Postgres 无法连接主机 "..."、用户 "..."、数据库 "..."、SSL 关闭的 ERROR : no pg_hba. conf 条目

python - 使用 elasticsearch-dsl-py 索引和渗透文档

python - 如何使用 nose2 从给定的包中获取覆盖率报告

python - 如何在不处于顶层的情况下解决python多处理的 pickle 错误?

git - 强制 Git 在 merge 期间始终选择较新的版本?

GIT存储库: "invalid author/committer line - missing space before date"

git - 重击 : atom: command not found how to resolve this in windows?

heroku - 发布脚本失败并显示 "/bin/sh: 1: ./release-tasks.sh: Permission denied"