简体   繁体   中英

pip install from private repo but requirements from PyPi only installs private package

Unlike pip install from private repo but requirements from PyPi I am able to intall my package (daisy) from our private artifactory instance with:

pip3 install -i https://our-artifactory/pypi/simple daisy

The ouput is:

Looking in indexes: https://our-artifactory/api/pypi/simple
Collecting daisy
  Downloading https://our-artifactory/artifactory/api/pypi/my-repo/daisy/0.0.2/daisy-0.0.2-py3-none-any.whl (4.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.8/4.8 MB 12.1 MB/s eta 0:00:00
ERROR: Could not find a version that satisfies the requirement pandas<2.0.0,>=1.5.2 (from daisy) (from versions: none)
ERROR: No matching distribution found for pandas<2.0.0,>=1.5.2

When I then try to install pandas by itself it works:

pip3 install pandas
Collecting pandas
  Downloading pandas-1.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.2/12.2 MB 16.0 MB/s eta 0:00:00
Collecting python-dateutil>=2.8.1
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting pytz>=2020.1
  Downloading pytz-2022.7-py2.py3-none-any.whl (499 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 499.4/499.4 kB 4.1 MB/s eta 0:00:00
Collecting numpy>=1.20.3
  Downloading numpy-1.24.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.3/17.3 MB 18.9 MB/s eta 0:00:00
Collecting six>=1.5
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: pytz, six, numpy, python-dateutil, pandas
Successfully installed numpy-1.24.1 pandas-1.5.2 python-dateutil-2.8.2 pytz-2022.7 six-1.16.0

It is even the right version. Somehow I think in the first command it tries to get all dependencies from our private repo as well. Is there a way to get the package from the private repo and the dependencies from PyPI?

Btw, I'm working from a conda (miniforge) Python3.9 environment.

Edit: I got a bit further using:

pip3 install -i https://our-artifactory/artifactory/api/pypi/dl-innersource-pypi/simple daisy --extra-index-url https://pypi.org/simple

however it installs daisy from PyPI, I guess it's unfortunate that I picked an already existing name...

Edit: I can get it to work by specifying my daisy version, like this:

pip install --index-url https://my-artifactory/artifactory/api/pypi/dl-common-pypi/simple daisy==0.0.2

However, leaving out the version number reverts to fetching the PyPI version of daisy. Should this be considered a bug since I explicitly tell pip to look at my-artifactory first and then at public PyPI?

You can probably solve this with a solution like simpleindex . This will allow you to set some rules based on the project name to redirect pip towards an index or another.

Maybe something like this (untested):

[routes."daisy"]
source = "http"
to = "https://my-artifactory/artifactory/api/pypi/dl-common-pypi/simple/daisy/"

# Otherwise use PyPI.
[routes."{project}"]
source = "http"
to = "https://pypi.org/simple/{project}/"

[server]
host = "127.0.0.1"
port = 8000

But I guess some other index proxy software might be able to do this as well.

Some more on the topic in this discussion .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM