我想python setup.py develop
使用 ansible 在 virtualenv 中执行命令。怎么做?
可能是这样的:
- name: egg
shell: "python setup.py develop"
但我需要在 virtualenv 中执行它。我该怎么做?
我想python setup.py develop
使用 ansible 在 virtualenv 中执行命令。怎么做?
可能是这样的:
- name: egg
shell: "python setup.py develop"
但我需要在 virtualenv 中执行它。我该怎么做?
一种方法是从 virtualenv 的 bin 目录调用 python。
- name: egg
shell: "/path/to/env/bin/python setup.py develop"
我只是使用该pip -e
方法,通过pip 命令(保证 virtualenv 存在),将-e
参数添加到extra_args
. 例如:
- name: install MYPACKAGE in VIRTUALENV
pip: name='PATH OF YOUR PACKAGE'
extra_args='-e' # this creates a link rather then copying the files
virtualenv='PATH OF YOUR VIRTUALENV' # will be created if does not exist
或者,您可能希望指定 virtualenv 脚本的执行方式,例如。如果你需要 python3 添加:
virtualenv_command='python3 /PATH_TO_VE/virtualenv.py'
您也可以尝试将命令链接在一起。
- name: chained shell command
shell: "source /path/to/env/bin/activate; python setup.py develop"