Where to define the postactivate hook with virtualenvwrapper-win?

会有一股神秘感。 提交于 2020-01-02 03:45:17

问题


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"


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/27536538/where-to-define-the-postactivate-hook-with-virtualenvwrapper-win

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!