Search code examples
pythonpippipenv

What's the difference between `pipenv install --index` and `pipenv install --pypi-mirror`?


pipenv install command reference here.

-i, --index Target PyPI-compatible package index url.

--pypi-mirror Specify a PyPI mirror.

Besides, environment variable PIP_INDEX_URL corresponds to --index, PIPENV_PYPI_MIRROR corresponds to --pypi-mirror,

If I get a pypi mirror url, what's the difference between passing it as --index=<url> and as --pypi-mirror=<url>? It seems that both methods work for me.


Solution

  • this is an interesting question, the doc of pipenv is unclear on the difference of those two options, then the best source is its source code, as of version v2018.11.26, its behavior roughly like:

    • you could specify multiple --index, they formed the source list of packages, they could be the PyPI url or a private repository url.
    • only one --pypi-mirror could be specified.
    • if --pypi-mirror is used, for each PyPI source url in the source list, would be replaced with mirror url.
    • in the end, pipenv shell out all sources to pip install, with --index-url, and --extra-index-url option if there is more than one source.

    if you only install from PyPI, the net effect of both methods is the same.