Search code examples
pythondjangovirtualenvvirtualenvwrapperpyenv

triggering different app environments with pyenv-virtualenv


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?


Solution

  • I ended up adding environment variable export something='something-else' commands to the activate file ~/.pyenv/versions/my_venv/bin/activate in the spirit of autoenv after reading this forum reply elsewhere.