I'm deploying a Python Django app to Heroku, and I'd like to customize the requirements.txt file (by adding a git-backed dependency with password) only when I deploy to certain environments like Heroku. I'd love to set this in an environment variable or something, but I don't believe pip has any functionality like that. My idea was to use a hook that Heroku provides to place a script which would add to my requirements.txt before the dependencies are installed. Is that possible?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You can include a requirements file in another requirements file.
I typically keep a
requirements.txt
file in the root of the project that just includes other requirements files(usually prod or a base) and make arequirements/
folder with environment specific stuff. So locally I'dpip install -r requirements/dev.txt
and on the serverpip install -r requirements/prod.txt
.For your case with heroku, you need the root requirements.txt to be for heroku. So you can just use that file to include your heroku requirements file.
There's probably SOME way to tell heroku to use a different file. But this would be an easy way to get around it.
You can do standard HTTPS auth:
But a much cleaner way would be to host your own set of requirements, see: https://devcenter.heroku.com/articles/python-pip#private-indexes
For managing different environment requirements, you can simply use
requirements.txt
for production andrequirements-dev.txt
for local development, or one of @yellottyellott's suggestions for including dependencies from other files.