How to use several requirements.txt profiles with Django App at Heroku?

Viewed 19

I've been trying to deploy a Django web app at Heroku and I'm using this layout for requirements:

requirements/
├── base.txt
├── local.txt
├── production.txt
├── staging.txt
└── test.txt
requirements.txt

requirements.txt

# This file is expected by Heroku.

-r requirements/staging.txt  # I have to change this for each env

I thought that depending on an environment variable Heroku would pick the apropiate txt file. The thing is that after multiple attempts and searching the docs I realized that Heroku only picks requirements.txt and no other file. So I can only push to heroku for staging and if I need to push for another environment, I have to change requirements.txt in the repo or having an alternative branch only for this file.

I'm thinking of using Heroku for at least a couple of environments, so I'd like to be able to manage more than one Heroku environment. So I went to investigate and I learnt that is possible to make a setup.py excluding the requirements.txt and managing this, but while reading the docs I couldn't understand yet how can I make setup.py pick the good requirements file among the multiple ones I have.

I suppose somebody must have wanted to do this, although I saw that setup.py docs discourages this way of procedure.

I guess another way to do this would be to give away everything about requirements files (though I like them) and do it all through setup.py, which I'm not familiarized with, so I'm asking here the solutions I can use for installing my dependencies at Heroku and other environments while maintaining the different dependencies separated in each environment file.

Thanks in advance

0 Answers
Related