2012-12-22 71 views
1

tox.ini中指定hg依賴關係的正確方法是什麼?例如指定tox.ini中的hg依賴關係

[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。

回答

5

這是可能的指定範圍內deps = …在兩個方面善變的依賴性:

  • -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)。不幸的是善變的不支持Python 3的

0

通常這是指包膜蟒蛇破善變安裝的神器

在virtualenv中的Python 3

的包膜蟒蛇是簡單地用

工作最糟糕的事情