Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 822777 - dev-python/certifi: ModuleNotFoundError: No module named 'pkg_resources' (was: app-portage/pfl)
Summary: dev-python/certifi: ModuleNotFoundError: No module named 'pkg_resources' (was...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-10 06:38 UTC by Joonas Niilola
Modified: 2021-12-21 02:15 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joonas Niilola gentoo-dev 2021-11-10 06:38:46 UTC
----------
 # pfl
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.9/pfl", line 4, in <module>
    import pfl.pfl
  File "/usr/lib/python3.9/site-packages/pfl/pfl.py", line 8, in <module>
    import requests
  File "/usr/lib/python3.9/site-packages/requests/__init__.py", line 133, in <module>
    from . import utils
  File "/usr/lib/python3.9/site-packages/requests/utils.py", line 26, in <module>
    from . import certs
  File "/usr/lib/python3.9/site-packages/requests/certs.py", line 15, in <module>
    from certifi import where
  File "/usr/lib/python3.9/site-packages/certifi/__init__.py", line 1, in <module>
    from .core import contents, where
  File "/usr/lib/python3.9/site-packages/certifi/core.py", line 3, in <module>
    from certifi._patch import _verify_dist_info
  File "/usr/lib/python3.9/site-packages/certifi/_patch.py", line 4, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
----------

Works after installing dev-python/setuptools. You'll need to define 

  DISTUTILS_USE_SETUPTOOLS=rdepend

I'd appreciate a revbump too but guess it's not so necessary with this change.
Comment 1 Daniel Pielmeier gentoo-dev 2021-11-10 18:40:20 UTC
Strange, I removed dev-python/setuptools from my system and app-portage/pfl installed fine. Do I miss something?
Comment 2 Daniel Pielmeier gentoo-dev 2021-11-10 18:42:36 UTC
It also works properly at runtime.
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-11-10 18:46:05 UTC
certifi seems to be the issue here, maybe?
Comment 4 Daniel Pielmeier gentoo-dev 2021-11-10 18:59:03 UTC
(In reply to Sam James from comment #3)
> certifi seems to be the issue here, maybe?

Probably you are right.

However reading the stack trace again it looks like dev-python/requests requires dev-python/certifi. app-portage/pfl however depends on python/requests which should pull in dev-python/certifi and actually does. So it should be available even if not being pulled in by dev-python/setuptools but by dev-python/requests.
Comment 5 Daniel Pielmeier gentoo-dev 2021-11-10 19:03:07 UTC
Hm and dev-python/certifi then would need dev-python/setuptools as a dependency but this would introduce a circular dependency if I am not mistaken.
Comment 6 Daniel Pielmeier gentoo-dev 2021-11-10 19:05:59 UTC
Maybe dev-python/requests should use DISTUTILS_USE_SETUPTOOLS=rdepend as it pulls in dev-python/certifi directly!?
Comment 7 Joonas Niilola gentoo-dev 2021-11-10 19:30:19 UTC
Reading the python strace indeed makes it look like dev-python/certifi is the culprit here. CCing python team.

Full output:
----------
my-test-container-snap-tmp ~ # pfl
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.9/pfl", line 4, in <module>
    import pfl.pfl
  File "/usr/lib/python3.9/site-packages/pfl/pfl.py", line 8, in <module>
    import requests
  File "/usr/lib/python3.9/site-packages/requests/__init__.py", line 133, in <module>
    from . import utils
  File "/usr/lib/python3.9/site-packages/requests/utils.py", line 26, in <module>
    from . import certs
  File "/usr/lib/python3.9/site-packages/requests/certs.py", line 15, in <module>
    from certifi import where
  File "/usr/lib/python3.9/site-packages/certifi/__init__.py", line 1, in <module>
    from .core import contents, where
  File "/usr/lib/python3.9/site-packages/certifi/core.py", line 3, in <module>
    from certifi._patch import _verify_dist_info
  File "/usr/lib/python3.9/site-packages/certifi/_patch.py", line 4, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
my-test-container-snap-tmp ~ # emerge -1av setuptools

These are the packages that would be merged, in order:

Calculating dependencies  ... done!
[binary  N     ] dev-python/tomli-1.2.2-r1-1::gentoo  USE="-test" PYTHON_TARGETS="pypy3 python3_8 python3_9 python3_10" 0 KiB
[binary  N     ] dev-python/pyparsing-2.4.7-r1-1::gentoo  USE="-examples" PYTHON_TARGETS="pypy3 python3_8 python3_9 python3_10" 0 KiB
[binary  N     ] dev-python/packaging-21.0-1::gentoo  USE="-test" PYTHON_TARGETS="pypy3 python3_8 python3_9 python3_10" 0 KiB
[binary  N     ] dev-python/setuptools-58.2.0-r1-1::gentoo  USE="-test" PYTHON_TARGETS="pypy3 python3_8 python3_9 python3_10" 0 KiB
[binary  N     ] dev-python/setuptools_scm-6.3.2-1::gentoo  USE="-test" PYTHON_TARGETS="pypy3 python3_8 python3_9 python3_10" 0 KiB

Total: 5 packages (5 new, 5 binaries), Size of downloads: 0 KiB

!!! The following binary packages have been ignored due to non matching USE:

    =dev-lang/python-exec-2.4.8 -native-symlinks
    =dev-lang/python-exec-2.4.8 -native-symlinks

NOTE: The --binpkg-respect-use=n option will prevent emerge
      from ignoring these binary packages if possible.
      Using --binpkg-respect-use=y will silence this warning.

Would you like to merge these packages? [Yes/No] y
>>> Emerging binary (1 of 5) dev-python/tomli-1.2.2-r1::gentoo
>>> Emerging binary (2 of 5) dev-python/pyparsing-2.4.7-r1::gentoo
>>> Installing (1 of 5) dev-python/tomli-1.2.2-r1::gentoo
>>> Installing (2 of 5) dev-python/pyparsing-2.4.7-r1::gentoo
>>> Emerging binary (3 of 5) dev-python/packaging-21.0::gentoo
>>> Installing (3 of 5) dev-python/packaging-21.0::gentoo
>>> Emerging binary (4 of 5) dev-python/setuptools-58.2.0-r1::gentoo
>>> Installing (4 of 5) dev-python/setuptools-58.2.0-r1::gentoo
>>> Emerging binary (5 of 5) dev-python/setuptools_scm-6.3.2::gentoo
>>> Installing (5 of 5) dev-python/setuptools_scm-6.3.2::gentoo
>>> Jobs: 5 of 5 complete                           Load avg: 0.21, 0.05, 0.02
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.
my-test-container-snap-tmp ~ # pfl
writing xml file /tmp/pfluzsqmi4l.xml ...
working on (1 of 19) dev-lang/python-3.9.8
working on (2 of 19) sys-kernel/linux-headers-5.14
working on (3 of 19) sys-kernel/gentoo-kernel-bin-5.15.1
working on (4 of 19) dev-python/packaging-21.0
working on (5 of 19) dev-python/certifi-3021.3.16
working on (6 of 19) dev-python/setuptools_scm-6.3.2
working on (7 of 19) dev-python/tomli-1.2.2-r1
working on (8 of 19) dev-python/setuptools-58.2.0-r1
working on (9 of 19) dev-python/pyparsing-2.4.7-r1
working on (10 of 19) virtual/dist-kernel-5.15.1
working on (11 of 19) sys-libs/libseccomp-2.5.3
working on (12 of 19) sys-libs/pam-1.5.2-r1
working on (13 of 19) app-misc/ca-certificates-20211016.3.72
working on (14 of 19) sys-apps/kmod-29
working on (15 of 19) sys-apps/systemd-tmpfiles-249.5
working on (16 of 19) sys-apps/sandbox-2.29
working on (17 of 19) dev-libs/libgpg-error-1.43
working on (18 of 19) dev-libs/libpipeline-1.5.4
working on (19 of 19) dev-libs/libtasn1-4.18.0
uploading xml file /tmp/pfluzsqmi4l.xml.bz2 to https://upload.portagefilelist.de/data.php ...
deleting xml file /tmp/pfluzsqmi4l.xml.bz2 ...
----------
Comment 8 Joonas Niilola gentoo-dev 2021-11-23 13:05:22 UTC
Python team: Can I add DISTUTILS_USE_SETUPTOOLS=rdepend to certifi-3021.3.16?
Comment 9 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-11-23 15:12:45 UTC
(In reply to Joonas Niilola from comment #8)
> Python team: Can I add DISTUTILS_USE_SETUPTOOLS=rdepend to certifi-3021.3.16?

No, this will cause QA warnings.  I've submitted a proper fix upstream.

That said, if you expect bugs to be fixed, reassign them properly instead of hiding them inside completely irrelevant description.
Comment 10 Larry the Git Cow gentoo-dev 2021-12-21 02:14:48 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ee35be1dc88fca67d3845bf583d886912ca9bb73

commit ee35be1dc88fca67d3845bf583d886912ca9bb73
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2021-12-21 02:13:40 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-12-21 02:14:41 +0000

    dev-python/certifi: needs setuptools at runtime
    
    Bug: https://github.com/tiran/certifi-system-store/pull/17
    Closes: https://bugs.gentoo.org/822777
    Signed-off-by: Sam James <sam@gentoo.org>

 ...3021.3.16.ebuild => certifi-3021.3.16-r1.ebuild} |  7 ++++++-
 .../files/certifi-3021.3.16-setuptools.patch        | 21 +++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)