Pregunta

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?

¿Fue útil?

Solución

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

Otros consejos

This section of the documentation for an older version of PIP suggests that if PIP finds multiple definitions for a package (e.g. via --extra-index-url or --find-links), the last match will be used. Unfortunately, I cannot find this information in the current documentation, so it may have changed.

Perhaps something like this in your requirements file will work:

...
django-photologue
...

--find-links https://github.com/jdriscoll/django-photologue
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top