Pip: priority of private pypi server

I am using Artifactory to host a lot of python modules. A couple of times, a new python module at https://pypi.python.org/pypi will be loaded with the same name. This causes problems when someone tries to install one of my modules from Artifactory using pip. By default, pip looks for publicly available packages first.

Here's what I've tried:

1. I tried modifying the .pypirc file accordingly,

[distutils]
index-servers =
        artifactory
        pypi

with matching entries for the two index servers, but I'm pretty sure pip is ignoring this information.

2. I tried to manually specify which index server to use.

I can specify --index-url

or --extra-index-url

, but the latter doesn't help when the shared package has a higher version number than my private package. If I list the first one, then no public dependencies will be found! Like I can't win.

3. I tried to point dependency_links

in setup.py.

... but this is deprecated according to this answer: pip ignores dependency_links in setup.py file

How do I configure pip to prefer my Artifactory repository over the public one?

+3


source to share


1 answer


You can check if this works:

pip3 install --index-url https://artifactory.your.company.com/artifactory/api/pypi/your-pypi-here/simple --extra-index-url https://pypi.python.org/simple coolpackage

      

This can be placed inside ~ / .pip / pip.conf to make it the default.



[global]
index-url = https://artifactory.your.company.com/artifactory/api/pypi/your-pypi-here/simple
extra-index-url = https://pypi.python.org/simple

      

Then you can do

pip install coolpackage

      

+2


source







All Articles