tox如何在pip安装中提供可信主机?

时间:2018-01-25 23:02:57

标签: python ssl testing tox

我创建了本地pypi服务器,我在indexserver中添加了tox.ini config以指向我的本地pypi服务器。

$ cat tox.ini

[tox]
indexserver =
    default = https://localhost
    trusted_host = localhost

envlist = py27
skipdist = True

[testenv]
commands=
    flake8 MyLib
    py.test -l --cov=MyLib --cov-report term-missing --cov-report xml --no-cov-on-fail

当我运行tox命令时,它会给出ssl错误。

$ tox -rv
using tox.ini: /var/lib/jenkins/workspace/cicd-mylib/tox.ini
using tox-0.0.0.dev0 from /usr/lib/python2.6/site-packages/tox/__init__.pyc
GLOB sdist-make: /var/lib/jenkins/workspace/cicd-mylib/setup.py
  /var/lib/jenkins/workspace/cicd-mylib$ /usr/bin/python /var/lib/jenkins/workspace/cicd-mylib/setup.py sdist --formats=zip --dist-dir /var/lib/jenkins/workspace/cicd-mylib/.tox/dist >/var/lib/jenkins/workspace/cicd-mylib/.tox/log/tox-0.log
py27 recreate: /var/lib/jenkins/workspace/cicd-mylib/.tox/py27
  /var/lib/jenkins/workspace/cicd-mylib/.tox$ /usr/bin/python -m virtualenv --python /var/lib/jenkins/.pyenv/shims/python2.7 py27 >/var/lib/jenkins/workspace/cicd-mylib/.tox/py27/log/py27-0.log
py27 inst: /var/lib/jenkins/workspace/cicd-mylib/.tox/dist/MyLib-2.0.26.zip
  /var/lib/jenkins/workspace/cicd-mylib$ /var/lib/jenkins/workspace/cicd-mylib/.tox/py27/bin/pip install -i https://localhost /var/lib/jenkins/workspace/cicd-mylib/.tox/dist/MyLib-2.0.26.zip >/var/lib/jenkins/workspace/cicd-mylib/.tox/py27/log/py27-1.log
ERROR: invocation failed (exit code 1), logfile: /var/lib/jenkins/workspace/cicd-mylib/.tox/py27/log/py27-1.log
ERROR: actionid: py27
msg: installpkg
cmdargs: ['/var/lib/jenkins/workspace/cicd-mylib/.tox/py27/bin/pip', 'install', '-i', 'https://localhost', '/var/lib/jenkins/workspace/cicd-mylib/.tox/dist/MyLib-2.0.26.zip']

Processing ./.tox/dist/MyLib-2.0.26.zip
Collecting cython (from MyLib==2.0.26)
  Could not fetch URL https://localhost/cython/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661) - skipping
  Could not find a version that satisfies the requirement cython (from MyLib==2.0.26) (from versions: )
No matching distribution found for cython (from MyLib==2.0.26)

  /var/lib/jenkins/workspace/cicd-mylib$ /var/lib/jenkins/workspace/cicd-mylib/.tox/py27/bin/pip freeze >/var/lib/jenkins/workspace/cicd-mylib/.tox/py27/log/py27-2.log
py27 installed:
_______________________________________________________________________________________________________________ summary _______________________________________________________________________________________________________________
ERROR:   py27: InvocationError: /var/lib/jenkins/workspace/cicd-mylib/.tox/py27/bin/pip install -i https://localhost /var/lib/jenkins/workspace/cicd-mylib/.tox/dist/MyLib-2.0.26.zip (see /var/lib/jenkins/workspace/cicd-mylib/.tox/py27/log/py27-1.log)

当tox运行时,它没有在命令--trusted-host

中传递cmdargs: ['/var/lib/jenkins/workspace/cicd-mylib/.tox/py27/bin/pip', 'install', '-i', 'https://localhost', '/var/lib/jenkins/workspace/cicd-mylib/.tox/dist/MyLib-2.0.26.zip']变量

如何通过?

1 个答案:

答案 0 :(得分:1)

indexserver is deprecated将被删除。使用install_command

install_command=pip install --index-url=https://localhost --trusted-host=localhost {opts} {packages}