如何告诉tox使用PyPI镜像来安装包?

And*_*ikh 8 python testing pypi tox

有没有办法告诉tox测试自动化工具在安装所有软件包时使用PyPI镜像(显式测试依赖关系tox.ini和依赖关系setup.py)?

例如,pip install有一个非常有用的--use-mirrors选项,可以将镜像添加到包服务器列表中.

Mar*_*ers 7

Pip也可以使用环境变量进行配置,这tox使您可以在配置中进行设置:

setenv =
    PIP_USE_MIRRORS=...
Run Code Online (Sandbox Code Playgroud)

或者,您可以指定要使用的一系列索引服务器:

indexserver = 
    default = http://mypypi.org
    foobar = http://otherpypi.org
Run Code Online (Sandbox Code Playgroud)

default是使用的默认索引服务器,但可以使用其他名称deps从特定服务器获取列表中的依赖项:

deps = 
    :foobar:ham-spam-pkg
Run Code Online (Sandbox Code Playgroud)

  • [`indexserver`](https://tox.readthedocs.io/en/latest/config.html#conf-indexserver) 现已弃用。请参阅[有关该主题的讨论](https://github.com/tox-dev/tox/issues/1357)。该文档已在此 [_PR_](https://github.com/tox-dev/tox/pull/1728) 中更新。请参阅 ["_使用不同的默认 PyPI URL_"](https://tox.readthedocs.io/en/latest/example/basic.html#using-a- different-default-pypi-url) 和 ["_安装依赖项多个 PyPI 服务器_"](https://tox.readthedocs.io/en/latest/example/basic.html#installing-dependency-from-multiple-pypi-servers) 作为当前建议。 (2认同)

Max*_*Max 7

Tox 可以配置为从不同的默认 PyPI 服务器安装依赖项和包:

关于使用不同的默认 PyPI url 的 Tox 文档的链接


Pet*_*r K 7

由于indexserver弃用,并会被删除,--use-mirrors弃用,以及,你可以使用install_command(环境中的部分):

[testenv:my_env]
install_command=pip install --index-url=https://my.index-mirror.com --trusted-host=my.index-mirror.com {opts} {packages}
Run Code Online (Sandbox Code Playgroud)