Issue
I'm currently writing a deployment script for a django app using fabric. It seems necessary / useful to me to have a system for versioning the virtualenv that the app uses, in case a rollback is needed.
The most robust way I can think to do this is to create virtualenvs with the name equal to the md5 hash of the contents of the requirements file. this means that when the requirements change, the checksum will change and I can copy/update the virtualenv with a new hash and preserve the old hash virtualenv in case I need to rollback (then it's just a matter of switching a 'current' symlink).
Trouble is I'm using nested requirements file syntax in e.g. my production.txt requirements file (-r base.text
) so the md5 hash isn't going to take into account base requirements changes etc.
Is there any output pip can provide to parse these files prior to installing them? I don't want to have to install them then pip freeze just to figure out if something has changed.
Solution
Instead of using nested requirements, why not just use simple unix tools like cat
to calculate the md5. And just use multiple requirements files.
Or if you really want to us nested requirements, you will need to write a small shell script that grepped for -r file.txt and added it to your md5 calculation.
It's a neat idea though. Hashing the requirements.txt file and saving the env using that name. Makes for caching it easy and fast in distributed build systems too.
Answered By - dalore Answer Checked By - Marie Seifert (WPSolving Admin)