在tox.ini中指定hg依赖项

时间:2012-12-22 09:14:06

标签: python mercurial tox

tox.ini中指定hg依赖项的正确方法是什么。 e.g。

[testenv]
deps =
    hg+https://code.google.com/p/python-progressbar/

不幸的是,这不起作用,并且以下内容被吐出:

ERROR: invocation failed, logfile: /Users/brad/project/.tox/py33-dj/log/py33-dj-1.log
ERROR: actionid=py33-dj
msg=getenv
cmdargs=[local('/Users/brad/project/.tox/py33-dj/bin/pip'), 'install', '--download-cache=/Users/brad/.pip/downloads', 'hg+https://code.google.com/p/python-progressbar/', 'https://github.com/dag/attest/tarball/master', 'django-attest', 'django-celery', 'coverage', 'https://github.com/django/django/tarball/master']
env={'PYTHONIOENCODING': 'utf_8', 'TERM_PROGRAM_VERSION': '309', 'LOGNAME': 'brad', 'USER': 'brad', 'PATH': '/Users/brad/project/.tox/py33-dj/bin:/usr/local/share/python:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin', 'HOME': '/Users/brad', 'DISPLAY': '/tmp/launch-zayh2U/org.macosforge.xquartz:0', 'TERM_PROGRAM': 'Apple_Terminal', 'LANG': 'en_AU.UTF-8', 'TERM': 'xterm-256color', 'SHLVL': '1', '_': '/usr/local/share/python/tox', 'TERM_SESSION_ID': 'E8FC4113-C18B-4DB4-9594-C0909A132D76', 'SSH_AUTH_SOCK': '/tmp/launch-kia8RP/Listeners', 'SHELL': '/bin/bash', 'TMPDIR': '/var/folders/zr/m_ys6vwd1z19rqh73jd8z88w0000gn/T/', '__CF_USER_TEXT_ENCODING': '0x1F5:0:15', 'PWD': '/Users/brad/project', 'PIP_DOWNLOAD_CACHE': '/Users/brad/.pip/downloads', 'COMMAND_MODE': 'unix2003'}
abort: couldn't find mercurial libraries in [/usr/local/Cellar/mercurial/2.4.1/libexec /Users/brad/project/.tox/py33-dj/lib/python3.3/site-packages/distribute-0.6.31-py3.3.egg /Users/brad/project/.tox/py33-dj/lib/python3.3/site-packages/pip-1.2.1-py3.3.egg /Users/brad/project/.tox/py33-dj/lib/python33.zip /Users/brad/project/.tox/py33-dj/lib/python3.3 /Users/brad/project/.tox/py33-dj/lib/python3.3/plat-darwin /Users/brad/project/.tox/py33-dj/lib/python3.3/lib-dynload /usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3 /usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/plat-darwin /Users/brad/project/.tox/py33-dj/lib/python3.3/site-packages]
(check your install and PYTHONPATH)
Downloading/unpacking hg+https://code.google.com/p/python-progressbar/
  Cloning hg https://code.google.com/p/python-progressbar/ to /var/folders/zr/m_ys6vwd1z19rqh73jd8z88w0000gn/T/pip-88u_g0-build
  Complete output from command /usr/local/bin/hg clone --noupdate -q https://code.google.com/p/python-progressbar/ /var/folders/zr/m_ys6vwd1z19rqh73jd8z88w0000gn/T/pip-88u_g0-build:

----------------------------------------
Command /usr/local/bin/hg clone --noupdate -q https://code.google.com/p/python-progressbar/ /var/folders/zr/m_ys6vwd1z19rqh73jd8z88w0000gn/T/pip-88u_g0-build failed with error code 255 in None
Storing complete log in /Users/brad/.pip/pip.log

ERROR: could not install deps [hg+https://code.google.com/p/python-progressbar/]
_________________________________________ summary _________________________________________
ERROR:   py33-dj: could not install deps [hg+https://code.google.com/p/python-progressbar/]

pip.log中的最后一行是:

pip.exceptions.InstallationError: Command /usr/local/bin/hg clone --noupdate -q https://code.google.com/p/python-progressbar/ /var/folders/zr/m_ys6vwd1z19rqh73jd8z88w0000gn/T/pip-dakkvs-build failed with error code 255 in None

但运行pip install hg+https://code.google.com/p/python-progressbar/无效。

tox测试环境的目标是Python 3.3。

2 个答案:

答案 0 :(得分:5)

可以在deps = …中以两种方式指定mercurial依赖关系:

  • -ehg+https://code.google.com/p/python-progressbar/#egg=progressbar(没有空格)
  • hg+https://code.google.com/p/python-progressbar/

tox将deps中的每一行视为pip install的单个参数(包括空格)。

pip支持-e作为独立参数后跟URL或单个参数的前缀,即:

  • ['pip', 'install', '-e', 'hg+https://...']
  • ['pip', 'install', '-ehg+https://...']

但不会处理['pip', 'install', '-e hg+https://...'](因为URL被解析为包含空格字符)

那为什么不起作用?

Mercurial是在Python 2.7下安装的。当tox运行pip install时,它设置PATH env变量以引用它创建的Python 3.3 env。如果仔细查看错误消息,您将看到以下行:

abort: couldn't find mercurial libraries in …
/usr/local/bin/hg失败时由import mercurial脚本打印的

。通常,解决方案是为Python 3.3安装库(mercurial)。不幸的是,mercurial不支持Python 3。

答案 1 :(得分:0)

通常这是一个破坏的mercurial安装的工件,它引用了env python

在virtualenv for python 3中,env python是使用

最糟糕的事情