What is the conventional way to customise the changes made by a Python virtualenv bin/activate
script?
The Python virtualenv is activated by a $VENV/bin/activate
script. This script works primarily by setting environment variables specific to the virtualenv.
(This is different from the “bootstrap script” discussed in the Virtualenv documentation. Those are used once, when creating the virtualenv; they are not used when activating the virtualenv. This question is about the activate script.)
Many of the code bases for which I use a Python virtualenv, need additional (custom) environment variables set, at the same time the virtualenv is activated.
Edit the $VENV/bin/activate
script directly, to add statements that set more environment variables?
Write a custom wrapper script, that incidentally calls $VENV/bin/activate
?
Write a separate script with a specific name, that will be automatically called by the $VENV/bin/activate
script? Does such a thing exist?
Of course I could write a script with a different name, and instruct developers to run that instead. Or I could instruct them to install virtualenvwrapper
. But that is not the if-you-got-the-virtualenv-working-then-this-works-too automation that I'm seeking.
Instead, this question is asking how to hook into the existing convention, of activating the virtualenv with a known name $VENV/bin/activate
.
How about using virtualenvwrapper
and editing $VIRTUAL_ENV/bin/postactivate
?
http://virtualenvwrapper.readthedocs.io/en/latest/scripts.html#scripts-postactivate
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