question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] 62.0.0: `pkg_resources` module discards current `sys.path` sets it to default

See original GitHub issue

setuptools version

62.0.0

Python version

3.8.13

OS

Linux/x86_64

Additional environment information

N/A

Description

Looksl like pkg_resources module discards current sys.path sets it to default which makes especially annoing when in sphinx copy.py fiel needs to setup path to module which documentation needs to be generated.

Expected behavior

pkg_resources module should not discard current value of the sys.path.

How to Reproduce

--- a/docs/conf.py~     2020-12-11 11:41:37.000000000 +0000
+++ b/docs/conf.py      2021-12-25 23:58:01.750032165 +0000
@@ -18,7 +18,7 @@
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 #sys.path.insert(0, os.path.abspath('.'))
-sys.path.append(os.path.abspath('../'))
+sys.path.append(os.path.abspath('../src'))
 rqmt = pkg_resources.require('transaction')[0]

 # -- General configuration -----------------------------------------------------
  • execute in project tree strace -fe trace=file /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man 2>&1 | grep transaction

Output

[tkloczko@devel-g2v transaction-3.0.1]$ strace -fe trace=file /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man 2>&1 | grep transaction
getcwd("/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1", 1024) = 48
getcwd("/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1", 1024) = 48
getcwd("/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1", 1024) = 48
getcwd("/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1", 1024) = 48
getcwd("/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1", 1024) = 48
newfstatat(AT_FDCWD, "/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs", {st_mode=S_IFDIR|0755, st_size=340, ...}, 0) = 0
newfstatat(AT_FDCWD, "/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/build/sphinx/man", 0x7fff69d600e0, 0) = -1 ENOENT (No such file or directory)
getcwd("/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1", 1024) = 48
newfstatat(AT_FDCWD, "/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs/conf.py", {st_mode=S_IFREG|0644, st_size=8878, ...}, 0) = 0
getcwd("/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1", 1024) = 48
chdir("/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs") = 0
openat(AT_FDCWD, "/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs/conf.py", O_RDONLY|O_CLOEXEC) = 3
getcwd("/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs", 1024) = 53
newfstatat(AT_FDCWD, "/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs/conf.py", {st_mode=S_IFREG|0644, st_size=8878, ...}, 0) = 0
openat(AT_FDCWD, "/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs/conf.py", O_RDONLY|O_CLOEXEC) = 3
chdir("/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1") = 0
newfstatat(AT_FDCWD, "/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs/conf.py", {st_mode=S_IFREG|0644, st_size=8878, ...}, 0) = 0
  File "/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs/conf.py", line 22, in <module>
    rqmt = pkg_resources.require('transaction')[0]
pkg_resources.DistributionNotFound: The 'transaction' distribution was not found and is required by the application
  File "/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs/conf.py", line 22, in <module>
    rqmt = pkg_resources.require('transaction')[0]
pkg_resources.DistributionNotFound: The 'transaction' distribution was not found and is required by the application
  File "/home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/docs/conf.py", line 22, in <module>
    rqmt = pkg_resources.require('transaction')[0]
pkg_resources.DistributionNotFound: The 'transaction' distribution was not found and is required by the application

On above otput there is no try to opening /home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/src/transaction.{egg|dist}-info.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
abravalhericommented, Apr 22, 2022

Yes, I believe the eventual migration from pkg_resources to importlib.{metadata,resources} is the direction the community is moving towards.

0reactions
kloczekcommented, Apr 27, 2022

I’ve updated list of modules which are still using pkg_resources. Below are sucessfull migrations: https://github.com/mcmtroffaes/sphinxcontrib-bibtex/pull/299

Read more comments on GitHub >

github_iconTop Results From Across the Web

No module named pkg_resources - python - Stack Overflow
This error message is caused by a missing/broken Python setuptools package. ... (twisted set in my case) has broken the path python uses...
Read more >
The initialization of the sys.path module search path — Python ...
A module search path is initialized when Python starts. This module search path may be accessed at sys.path. The first entry in the...
Read more >
Easy Install - setuptools 65.6.3.post20221220 documentation
Easy Install is a python module ( easy_install ) bundled with setuptools that lets you automatically download, build, install, and manage Python packages....
Read more >
setuptools 2.1.2 - PyPI
Easily download, build, install, upgrade, and uninstall Python packages.
Read more >
Loading collections - Invoke documentation
Candidate modules/packages are introspected to make sure they can actually be used as valid task collections. Any that fail are discarded, the sys.path...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found