Search code examples
pythontestingpypitox

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


Is there a way to tell the tox test automation tool to use the PyPI mirrors while installing all packages (explicit testing dependencies in tox.ini and dependencies from setup.py)?

For example, pip install has a very useful --use-mirrors option that adds mirrors to the list of package servers.


Solution

  • 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.