9

我想python setup.py develop使用 ansible 在 vi​​rtualenv 中执行命令。怎么做?

可能是这样的:

- name: egg
  shell: "python setup.py develop"

但我需要在 virtualenv 中执行它。我该怎么做?

4

3 回答 3

8

一种方法是从 virtualenv 的 bin 目录调用 python。

- name: egg
  shell: "/path/to/env/bin/python setup.py develop"
于 2014-06-27T10:09:39.330 回答
5

我只是使用该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'
于 2015-07-14T08:38:30.947 回答
2

您也可以尝试将命令链接在一起。

- name: chained shell command
  shell: "source /path/to/env/bin/activate; python setup.py develop"
于 2014-07-09T17:27:56.813 回答