Bug 1579367 - pkg_resources.DistributionNotFound: The 'rpm-py-installer' distribution was not found and is required by rpkg
Summary: pkg_resources.DistributionNotFound: The 'rpm-py-installer' distribution was n...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: rpkg
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: cqi
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1579422 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-17 13:14 UTC by Miro Hrončok
Modified: 2018-06-06 13:00 UTC (History)
12 users (show)

Fixed In Version: rpkg-1.54-2.fc28 rpkg-1.54-2.fc27 rpkg-1.54-2.el6 rpkg-1.54-2.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-05-23 15:40:36 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miro Hrončok 2018-05-17 13:14:47 UTC
Description of problem: fedpkg doesn't work at all, it errors with

pkg_resources.DistributionNotFound: The 'rpm-py-installer' distribution was not found and is required by rpkg


Version-Release number of selected component (if applicable): fedpkg-1.33-1.fc29


How reproducible: Easy


Steps to Reproduce:
1. fedpkg

Actual results:
Traceback (most recent call last):
  File "/usr/bin/fedpkg", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3088, in <module>
    @_call_aside
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3072, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3101, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 574, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 892, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 778, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'rpm-py-installer' distribution was not found and is required by rpkg


Expected results: no error :)

Comment 1 Miro Hrončok 2018-05-17 13:21:04 UTC
rpkg depedns on rpm-py-installer but in fact in Fedora it depends on python3-rpm. So we should patch setup.py in Fedora spec to not have this:

$ cat /usr/lib/python3.6/site-packages/rpkg-1.54-py3.6.egg-info/requires.txt
...
rpm-py-installer


However, it later fails with:

pkg_resources.DistributionNotFound: The 'koji>=1.15' distribution was not found and is required by rpkg


And even if I remove koji, it fails with:

$ fedpkg
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/fedpkg/__main__.py", line 84, in main
    sys.exit(client.args.command())
AttributeError: 'Namespace' object has no attribute 'command'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/fedpkg", line 11, in <module>
    load_entry_point('fedpkg==1.33', 'console_scripts', 'fedpkg')()
  File "/usr/lib/python3.6/site-packages/fedpkg/__main__.py", line 89, in main
    (client.args.command.__name__, e))
AttributeError: 'Namespace' object has no attribute 'command'

But that's a different problem and still allows to run a fedpkg sub-commnad.

Comment 2 Miro Hrončok 2018-05-17 13:34:36 UTC
https://pagure.io/rpkg/pull-request/319

Comment 3 Miro Hrončok 2018-05-17 16:42:36 UTC
*** Bug 1579422 has been marked as a duplicate of this bug. ***

Comment 4 Jun Aruga 2018-05-17 17:27:45 UTC
Here is what another python project fixed this kind of issue.
https://github.com/rebase-helper/rebase-helper/blob/master/setup.py

Comment 5 Jun Aruga 2018-05-17 18:30:16 UTC
Sorry, maybe I should add a note on the document of rpm-py-installer for people to consider this situation.
I opened the ticket here.
https://github.com/junaruga/rpm-py-installer/issues/134

Comment 6 cqi 2018-05-18 01:20:57 UTC
For the python3-koji, the package does not include egg-info

docker run --rm -i -t registry.fedoraproject.org/fedora:28
[root@bd497b97ff79 /]# dnf install python3-koji
[snip]
[root@bd497b97ff79 /]# python3
Python 3.6.4 (default, Feb 24 2018, 19:29:29) 
[GCC 8.0.1 20180222 (Red Hat 8.0.1-0.16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
>>> pkg_resources.get_distribution('koji')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 564, in get_distribution
    dist = get_provider(dist)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 436, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 984, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 870, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'koji' distribution was not found and is required by the application
>>> 
[root@bd497b97ff79 /]# rpm -q --list python3-koji
/usr/lib/python3.6/site-packages/koji
/usr/lib/python3.6/site-packages/koji/__init__.py
/usr/lib/python3.6/site-packages/koji/__pycache__
/usr/lib/python3.6/site-packages/koji/__pycache__/__init__.cpython-36.opt-1.pyc
/usr/lib/python3.6/site-packages/koji/__pycache__/__init__.cpython-36.pyc
/usr/lib/python3.6/site-packages/koji/__pycache__/plugin.cpython-36.opt-1.pyc
/usr/lib/python3.6/site-packages/koji/__pycache__/plugin.cpython-36.pyc
/usr/lib/python3.6/site-packages/koji/__pycache__/util.cpython-36.opt-1.pyc
/usr/lib/python3.6/site-packages/koji/__pycache__/util.cpython-36.pyc
/usr/lib/python3.6/site-packages/koji/__pycache__/xmlrpcplus.cpython-36.opt-1.pyc
/usr/lib/python3.6/site-packages/koji/__pycache__/xmlrpcplus.cpython-36.pyc
/usr/lib/python3.6/site-packages/koji/plugin.py
/usr/lib/python3.6/site-packages/koji/util.py
/usr/lib/python3.6/site-packages/koji/xmlrpcplus.py
/usr/lib/python3.6/site-packages/koji_cli
/usr/lib/python3.6/site-packages/koji_cli/__init__.py
/usr/lib/python3.6/site-packages/koji_cli/__pycache__
/usr/lib/python3.6/site-packages/koji_cli/__pycache__/__init__.cpython-36.opt-1.pyc
/usr/lib/python3.6/site-packages/koji_cli/__pycache__/__init__.cpython-36.pyc
/usr/lib/python3.6/site-packages/koji_cli/__pycache__/commands.cpython-36.opt-1.pyc
/usr/lib/python3.6/site-packages/koji_cli/__pycache__/commands.cpython-36.pyc
/usr/lib/python3.6/site-packages/koji_cli/__pycache__/lib.cpython-36.opt-1.pyc
/usr/lib/python3.6/site-packages/koji_cli/__pycache__/lib.cpython-36.pyc
/usr/lib/python3.6/site-packages/koji_cli/commands.py
/usr/lib/python3.6/site-packages/koji_cli/lib.py

I'm going to file an issue for koji as well. rpkg might have to be patched before Koji team fixes it.

Comment 7 cqi 2018-05-18 02:24:49 UTC
(In reply to Jun Aruga from comment #4)
> Here is what another python project fixed this kind of issue.
> https://github.com/rebase-helper/rebase-helper/blob/master/setup.py

Thank you for the info. After installing rpm-py-installer, there are both distributions rpm-py-installer and rpm. Also in a f28 container,

>>> import pkg_resources
>>> pkg_resources.get_distribution('rpm')
rpm 4.14.1 (/root/env/lib/python3.6/site-packages/rpm-4.14.1-py3.6-linux-x86_64.egg)
>>> pkg_resources.get_distribution('rpm-py-installer')
rpm-py-installer 0.7.0 (/root/env/lib/python3.6/site-packages)

I think, for the use case of rpkg, we could do

try:
    import rpm
except ImportError:
    rpm = None
if rpm is None:
    # For the case of running in a clean Python virtualenv.
    # Next time, rpm will be available.
    install_requires.append('rpm-py-installer')
else:
    # Whatever in a Python virtualenv with rpm-py-installer installed,
    # and python3-rpm is installed in the system.
    install_requires.append('rpm')

Comment 8 cqi 2018-05-18 02:27:19 UTC
(In reply to cqi from comment #6)

> I'm going to file an issue for koji as well. rpkg might have to be patched
> before Koji team fixes it.

There was one filed a few days ago https://pagure.io/koji/issue/912

Comment 9 Jun Aruga 2018-05-18 08:50:04 UTC
> Thank you for the info. After installing rpm-py-installer, there are both distributions rpm-py-installer and rpm. Also in a f28 container,

Yes, that's an expected behavior.

> I think, for the use case of rpkg, we could do
> ...

Sure, it looks good logic.

Comment 10 Jun Aruga 2018-05-18 09:04:20 UTC
Or like this as the simpler version.

```
try:
    import rpm
except ImportError:
    # For the case of running in a clean Python virtualenv.
    # Next time, rpm will be available.
    install_requires.append('rpm-py-installer')
else:
    # Whatever in a Python virtualenv with rpm-py-installer installed,
    # and python3-rpm is installed in the system.
    install_requires.append('rpm')
```

Comment 11 cqi 2018-05-18 10:17:15 UTC
(In reply to Jun Aruga from comment #10)
> Or like this as the simpler version.
> 
> ```
> try:
>     import rpm
> except ImportError:
>     # For the case of running in a clean Python virtualenv.
>     # Next time, rpm will be available.
>     install_requires.append('rpm-py-installer')
> else:
>     # Whatever in a Python virtualenv with rpm-py-installer installed,
>     # and python3-rpm is installed in the system.
>     install_requires.append('rpm')
> ```

Awesome! :)

Comment 12 Miro Hrončok 2018-05-18 10:28:55 UTC
Hopefully importing rpm during rpmbuild won't blow up into our faces.

If it does, try to pkg_resources.get_distribution('rpm') without importing it.

Comment 13 Miro Hrončok 2018-05-18 10:30:48 UTC
import pkg_resources

try:
    pkg_resources.get_distribution('rpm')
except pkg_resources.DistributionNotFound:
    install_requires.append('rpm-py-installer')
else:
    install_requires.append('rpm')

Comment 14 cqi 2018-05-19 02:05:23 UTC
Thank you all for the great ideas.

PR: https://pagure.io/rpkg/pull-request/320

Comment 15 Miro Hrončok 2018-05-21 08:17:34 UTC
Just to be clear, the workaround is to remove koji and rpm-py-installer lines from /usr/lib/python3.6/site-packages/rpkg-1.54-py3.6.egg-info/requires.txt

Comment 16 Miro Hrončok 2018-05-21 08:20:36 UTC
(In reply to Miro Hrončok from comment #1)
> And even if I remove koji, it fails with:
> 
> $ fedpkg
> Traceback (most recent call last):
>   File "/usr/lib/python3.6/site-packages/fedpkg/__main__.py", line 84, in
> main
>     sys.exit(client.args.command())
> AttributeError: 'Namespace' object has no attribute 'command'
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "/usr/bin/fedpkg", line 11, in <module>
>     load_entry_point('fedpkg==1.33', 'console_scripts', 'fedpkg')()
>   File "/usr/lib/python3.6/site-packages/fedpkg/__main__.py", line 89, in
> main
>     (client.args.command.__name__, e))
> AttributeError: 'Namespace' object has no attribute 'command'
> 
> But that's a different problem and still allows to run a fedpkg sub-commnad.

This has been reported upstream as https://pagure.io/fedpkg/issue/221

Comment 17 Miro Hrončok 2018-05-21 08:30:17 UTC
May I suggest to stop looking for a perfect solution and patch this quickly in spec as soon as possible? People are asking on mailing list about this, this affects a lot of Fedora packagers.

Comment 18 cqi 2018-05-21 08:44:21 UTC
A patch here and under testing now. https://src.fedoraproject.org/rpms/rpkg/pull-request/19. Once it is ready and merged, it'll be quick to build new packages.

Comment 19 Yanko Kaneti 2018-05-21 09:30:05 UTC
@cqi, with all due respect breaking stuff for everyone on Thursday then still waiting for someone else to review/fix/push on Monday is not really ideal packager conduct.

Comment 20 cqi 2018-05-21 10:11:22 UTC
Rawhide has new build. Please try it.

Comment 21 Yanko Kaneti 2018-05-21 10:15:00 UTC
(In reply to cqi from comment #20)
> Rawhide has new build. Please try it.

rpkg-1.54-2.fc29  works for me. Thanks

Comment 22 Fedora Update System 2018-05-21 10:15:32 UTC
rpkg-1.54-2.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-e720c88e8f

Comment 23 Fedora Update System 2018-05-21 10:16:06 UTC
rpkg-1.54-2.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2018-035317d7ea

Comment 24 Fedora Update System 2018-05-21 10:18:12 UTC
rpkg-1.54-2.el6 has been submitted as an update to Fedora EPEL 6. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2018-ad307d35b4

Comment 25 Fedora Update System 2018-05-21 10:18:49 UTC
rpkg-1.54-2.el7 has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2018-69704fa410

Comment 26 Fedora Update System 2018-05-21 15:00:50 UTC
rpkg-1.54-2.el7 has been pushed to the Fedora EPEL 7 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2018-69704fa410

Comment 27 Fedora Update System 2018-05-21 15:08:26 UTC
rpkg-1.54-2.el6 has been pushed to the Fedora EPEL 6 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2018-ad307d35b4

Comment 28 Fedora Update System 2018-05-21 16:35:47 UTC
rpkg-1.54-2.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-035317d7ea

Comment 29 Fedora Update System 2018-05-21 17:15:54 UTC
rpkg-1.54-2.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-e720c88e8f

Comment 30 Fedora Update System 2018-05-23 15:40:36 UTC
rpkg-1.54-2.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.

Comment 31 Fedora Update System 2018-05-26 21:10:28 UTC
rpkg-1.54-2.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.

Comment 32 Fedora Update System 2018-06-06 12:23:15 UTC
rpkg-1.54-2.el6 has been pushed to the Fedora EPEL 6 stable repository. If problems still persist, please make note of it in this bug report.

Comment 33 Fedora Update System 2018-06-06 13:00:31 UTC
rpkg-1.54-2.el7 has been pushed to the Fedora EPEL 7 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.