I am building an app that uses photologue
and a few other packages that have photologue
as a dependency (e.g., cmsplugin-photologue
). However, I need to use a modified version of photologue
hosted on github. All this will then be deployed on Heroku, which means that installations of dependencies is done solely through a requirements.txt
file.
In principle this is done quite easily: I can just add the repository to the requirements file as described here and it will be installed. The problem is that the original photologue
is installed too and ends up the one being used.
So the general question is: Using pip
, how can I replace an application that is a dependency of several apps with my own version of that application?
Unfortunately, pip makes no attempt to resolve dependency conflicts. For example, if you install two packages, package A may require a different version of a dependency than package B requires. Pip can install from either Source Distributions (sdist) or Wheel (. whl) files.
Pip does not provide true dependency resolution, but this can be solved by using it in conjunction with a requirements. txt file. Requirements. txt files can be used to make pip resolve dependency conflicts between different packages.
just use the -U
or --upgrade
option to replace the original package in your venv with your custom version:
cd myapp && venv/bin/pip install -U git+https://github.com/jcomeauictx/django-crispy-forms.git
then in your requirements.txt replace the line
django-crispy-forms==1.4.0
with
git+https://github.com/jcomeauictx/django-crispy-forms.git
when you push to your heroku instance, you should see something like:
-----> 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With