with virtualenvwrapper, I could setup separate virtualenvs and calling workon venv have them link to specific settings files (ex. test_settings.py or dev_settings.py) I preset using hooks in the virtualenv's bin - preactivate, postactivate, predeactivate and postdeactivate.
Is there something equivalent for pyenv? pyenv-virtualenv automatically switches virtualenvs based on .python-version set in the current directory, so there's no need to activate and the .pyenv/versions/venv/bin/ dir doesn't have the compliment of hooks that virtualwrapper has anyway.
I can easily create different virtualenvs for my various app environments but how can I link them to different environment-specific app settings?
Two ideas:
The obvious one: Try the pyenv-virtualenvwrapper
plugin to pyenv?
You can add hooks for a specific pyenv command in $PYENV_ROOT/pyenv.d/<command>
. You can do this even for for pyenv's “porcelain” commands which aren't normally called directly by the user. You could write a hook for activate
that changes settings based on the name of the virtualenv you're switching to. (pyenv-virtualenv implicitly pyenv activate
when switching to a virtualenv). Note: I've created pyenv hooks, but not for activate
, so this is just an idea…
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.