Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot collect patch dependency on a local Artifactory Pypi repository

Tags:

While testing out conan, I had to "pip install" it.

As I am working in a fully offline environment, my expectation was that I could simply

  • Manually deploy all dependencies listed in https://github.com/conan-io/conan/blob/master/conans/requirements.txt to a local Pypi repository called myrepo-python
  • Install conan with

    pip3 install --index http://myserver/artifactory/api/pypi/myrepo-python/simple conan

This works fine for some packages and then fails for the dependency on patch == 1.16

[...]
Collecting patch==1.16 (from conan)
  Could not find a version that satisfies the requirement patch==1.16 (from conan) (from versions: )
No matching distribution found for patch==1.16 (from conan)

Looking into the Artifactory logs, this shows that even though I manually deployed patch-1.16.zip (from https://pypi.org/project/patch/1.16/#files) into the repository, it is not present in the index...

  • The .pypi/simple.html file doesn't contain an entry for 'patch' (checked from the Artifactory UI)
  • The server logs ($ARTIFACTORY_HOME/logs/artifactory.log) show the file being added to the indexing queue but don't contain a line saying that it got indexed

Does anyone know why patch-1.16.zip is not indexed by Artifactory?

This is on Artifactory 5.8.4.

For now, my only workaround is to gather all the dependencies into a local path and point pip3 at it

scp conan-1.4.4.tar.gz installserver:/tmp/pip_cache
[...]
scp patch-1.16.zip installserver:/tmp/pip_cache
[...]
scp pyparsing-2.2.0-py2.py3-none-any.whl installserver:/tmp/pip_cache
ssh installserver
installserver$ pip3 install --no-index --find-links="/tmp/pip_cache" conan
like image 700
Arnaud Jeansen Avatar asked Jun 20 '18 09:06

Arnaud Jeansen


People also ask

What is Pypirc file?

A . pypirc file allows you to define the configuration for package indexes (referred to here as “repositories”), so that you don't have to enter the URL, username, or password whenever you upload a package with twine or flit.

What is PyPI repository?

The Python Package Index (PyPI) is a repository of software for the Python programming language. PyPI helps you find and install software developed and shared by the Python community. Learn about installing packages. Package authors use PyPI to distribute their software.


1 Answers

The reason you are unable to install the "patch" Pypi package via Artifactory is that it does not comply with the Python spec.

Based on Python spec (https://www.python.org/dev/peps/pep-0314/ and https://packaging.python.org/tutorials/packaging-projects/), the structure of a Python package should be, for example:

└── patch-1.16.zip
    └── patch-1.16
        ├── PKG-INFO
        ├── __main__.py
        ├── patch.py
        └── setup.py

However, the zip archive (can be found here https://pypi.org/project/patch/1.16/#files) is structured like that:

└── patch-1.16.zip
    ├── PKG-INFO
    ├── __main__.py
    ├── patch.py
    └── setup.py

Artifactory is searching for the metadata file (PKG-INFO in this case) in a certain pattern (inside any folder). Since the PKG-INFO is in the root of the zip (and not in a folder), it cannot find it, therefore, this package's metadata will not be calculated and it will not appear in the "simple" index file (see the error in artifactory.log). As a result, you are unable to install it with pip.

Workaround:

What you can do is manually changing the structure to the correct one.

Create a folder named patch-1.16 and extract the zip to it. Then, zip the whole folder, so you will get the structure like the example above. Finally, deploy this zip to Artifactory. This time, the PKG-INFO file will be found, the metadata will be calculated and pip will be able to install it.

like image 133
avivblo Avatar answered Oct 11 '22 15:10

avivblo