[英]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. 使用virtualenvwrapper,我可以设置单独的virtualenvs并调用workon venv将它们链接到特定的设置文件(例如test_settings.py或dev_settings.py)我使用virtualenv的bin中的钩子进行预设 - preactivate,postactivate,predeactivate和postdeactivate。
Is there something equivalent for pyenv? 是否有类似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.
pyenv-virtualenv基于当前目录中设置的.python-version自动切换virtualenvs,因此无需激活,并且.pyenv / versions / venv / bin / dir也没有虚拟包装器所具有的钩子的赞美。
I can easily create different virtualenvs for my various app environments but how can I link them to different environment-specific app settings? 我可以轻松地为各种应用程序环境创建不同的virtualenv,但是如何将它们链接到不同的特定于环境的应用程序设置?
Two ideas: 两个想法:
The obvious one: Try the pyenv-virtualenvwrapper
plugin to pyenv? 显而易见的一个:尝试
pyenv-virtualenvwrapper
插件到pyenv?
You can add hooks for a specific pyenv command in $PYENV_ROOT/pyenv.d/<command>
. 您可以在
$PYENV_ROOT/pyenv.d/<command>
为特定的pyenv命令添加挂钩。 You can do this even for for pyenv's “porcelain” commands which aren't normally called directly by the user. 您甚至可以为pyenv的“瓷器”命令执行此操作,这些命令通常不会由用户直接调用。 You could write a hook for
activate
that changes settings based on the name of the virtualenv you're switching to. 您可以编写一个用于
activate
的挂钩,根据您要切换到的virtualenv的名称更改设置。 (pyenv-virtualenv implicitly pyenv activate
when switching to a virtualenv). (切换到virtualenv时,pyenv-virtualenv隐式
pyenv activate
)。 Note: I've created pyenv hooks, but not for activate
, so this is just an idea… 注意:我已经创建了pyenv钩子,但不是为了
activate
,所以这只是一个想法......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.