Running various applications with pyenv-virtualenv

with virtualenvwrapper, I could set up individual virtual names and call workon venv, linking them to specific settings files (for example, test_settings.py or dev_settings.py). I specify the use of hooks in a virtual bin - preactivate, postactivate, predeactivate and postdeactivate.

Is there something equivalent for pyenv? pyenv-virtualenv automatically switches virtualenvs based on the .python version installed in the current directory, so there is no need to activate, and .pyenv / versions / venv / bin / dir does not have the compliment of hooks that VirtualVrapper has anyway.

I can easily create different virtualenv for different applications, but how can I associate them with different application settings for the environment?

+5
source share
2 answers

As a result, I added the export something='something-else' environment variable commands to the ~/.pyenv/versions/my_venv/bin/activate activation file in the spirit of autoenv after reading this forum response elsewhere.

+1
source

Two ideas:

  • Obvious: try the pyenv-virtualenvwrapper plugin for pyenv?

  • You can add hooks for a specific pyenv command in $PYENV_ROOT/pyenv.d/<command> . You can do this even for pyenvs china commands, which arent usually called directly by the user. You can write a hook for activate , which changes the settings based on the name of the virtual access you are switching to. (pyenv-virtualenv implicitly pyenv activate when switching to virtualenv). Note: Ive created pyenv hooks, but not for activate , so this is just an idea ...

0
source

All Articles