I'm using virtualenvwrapper-win and want to use the postactivate hook of virtualenvwrapper to set environment variables. However it seems virtualenvwrapper-win doesn't include a postactivate file, and I haven't been able to get it to work by creating my own. Does anybody know how to get the postactivate hook to work with virtualenvwrapper-win?
I want to include this in postactivate to set an environment variable: SET APP_SETTINGS="example.setting"
I actually solved it myself. You can put any environment variables in the activate.bat file in the Scripts folder of your virtualenv.
If you have already defined your VIRTUALENVWRAPPER_HOOK_DIR
variable, just add this line to workon.bat
.
call "%VIRTUALENVWRAPPER_HOOK_DIR%\postactivate.bat"
Just make sure you put it above :END
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