Search code examples
pipsetuptoolspypi

Pip install package not from pypi, whose name is the same as one in pypi ( + with dependencies from pypi )


I have a python package, hosted on azure (vsts), not on pypi, whose dependencies are python packages that live in pypi.

My package has the same name as a package that lives on pypi, I discovered.

Is there a way of installing my package with pip, specifying that my package must be searched on vsts before, while the dependencies can be grabbed from pypi?

If I use the --index-url option:

pip install <my-package> --index-url https://<my-package>:<PAT>@<url>/<proj>/_packaging/<my-package>/pypi/simple/

pip is able to locate my package, tries to install it, but it fails to install any dependency (because it searches for all of them in the same url, which is wrong because I am not hosting, say, my own version of numpy or other packages on vsts).

(This is the problem: pip install producing "Could not find a version that satisfies the requirement" )

If instead I use the --extra-index-url option:

pip install <my-package> --extra-index-url https://<my-package>:<PAT>@<url>/<proj>/_packaging/<my-package>/pypi/simple/

all the dependencies are found, but the problem is that this does not install my package, but the package with the same name that lives in pypi!

Even if --extra-index-url is there, it seems that pypi is given priority, and therefore my package that would be found at the url I specified is shadowed and doesn't get correctly found and installed.

Is there a way to, say, tell pip that it should give priority to my --extra-index-url? Or to give pip an --index-url which should only be valid for one package but not for its dependencies?


Solution

  • You need index URL pointing to VSTS and extra URL to PyPI:

    pip install --index-url=https://<my-package>:<PAT>@<url>/<proj>/_packaging/<my-package>/pypi/simple/ --extra-index-url=https://pypi.org/simple/ <my-package>