Where to define the postactivate hook with virtualenvwrapper-win?
Asked Answered
S

2

6

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"

Segregation answered 17/12, 2014 at 23:10 Comment(0)
S
6

I actually solved it myself. You can put any environment variables in the activate.bat file in the Scripts folder of your virtualenv.

Segregation answered 17/12, 2014 at 23:24 Comment(1)
A problem might be that the moment you deactivate the environment, if you do not clean up those variables, they will remain in the parent session/console. In short they will leak outside of the environment. So probably an "unset" command must should be placed in deactivate.bat.Sarto
P
1

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

Polly answered 30/10, 2015 at 17:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.