[Rpm-maint] [rpm-software-management/rpm] Python module's name changed unnecessarily, making it impossible to express dependencies on it (#373)

Adam Williamson notifications at github.com
Fri Dec 22 18:37:30 UTC 2017


No. No, not that either. The *code* works fine, if it actually gets run, because the name of the module itself (`rpm`) has not changed. This is about bits of Python-ecosystem infrastructure that allow for the expression and checking of dependencies. Specifically, in my case, `setuptools` and `tox`, but there are certainly others.

The way I understand it, these are usually implemented via the egg format. To look at it in Fedora / RH terms, by policy Python library packages for those distros have to include egg files, where the library's build scripts produce them:

https://fedoraproject.org/wiki/Packaging:Python#Files_to_include

"*.egg-info files or directories. If these are generated by the module's build scripts they must be included in the package because they might be needed by other applications and modules at runtime."

The python(2,3)-rpm packages *do* include these egg files:

    [adamw at adam openqa (master %)]$ rpm -ql python2-rpm | grep egg
    /usr/lib64/python2.7/site-packages/rpm-4.14.0-py2.7.egg-info
    [adamw at adam openqa (master %)]$ rpm -ql python3-rpm | grep egg
    /usr/lib64/python3.6/site-packages/rpm-4.14.0-py3.6.egg-info

and the 'name' in question is included in those. On a Fedora Rawhide system (27 is the same):

    [adamw at adam openqa (master %)]$ grep Name /usr/lib64/python2.7/site-packages/rpm-4.14.0-py2.7.egg-info
    Name: rpm

But on a Fedora 26 system:

    [adamwill at openqa01 ~][PROD]$ grep Name /usr/lib64/python2.7/site-packages/rpm_python-4.13.0.2-py2.7.egg-info
    Name: rpm-python

*That* is the problem.

When you're creating a Python module, if you do the normal thing and create a setuptools-style `setup.py` for it, you can express dependencies in this:

https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-dependencies

When setuptools is resolving these dependencies, it uses the 'name' expressed in the egg file. Which is the name *declared* in the `setup.py` for the library. That is, if I put `install_requires=['rpm']` in a `setup.py` file, when I try to install that Python library, setuptools will be satisfied if there is a library installed whose egg file declares its name to be `rpm`. *Not* if there is a library installed which would be loaded by an `import rpm` statement in Python code. So for older versions of RPM, if you want to declare that your Python project requires the Python RPM library in its `setup.py`, you have to do `install_requires=['rpm-python']`. Doing `install_requires=['rpm']` *does not work*: trying to install the library will fail, claiming no library called `rpm` is available or can be installed.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/373#issuecomment-353653360
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20171222/9b7365e9/attachment.html>


More information about the Rpm-maint mailing list