How to tell tox to use PyPI mirrors for installing packages?

Pip also can be configured using environment variables, which tox lets you set in the configuration:

setenv =
    PIP_USE_MIRRORS=...

Note that --use-mirrors has been deprecated; instead, you can set the PIP_INDEX_URL or PIP_EXTRA_INDEX_URL environment variables, representing the --index-url and --extra-index-url command-line options.

For example:

setenv = 
    PIP_EXTRA_INDEX_URL=http://example.org/index

would add http://example.org/index as an alternative index server, used if the main index doesn't have a package.


Since indexserver is deprecated and would be removed and --use-mirrors is deprecated as well, you can use install_command (in your environment section):

[testenv:my_env]
install_command=pip install --index-url=https://my.index-mirror.com --trusted-host=my.index-mirror.com {opts} {packages}