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] FileNotFoundError jaraco/text/Lorem ipsum.txt when importing pkg_resources

See original GitHub issue

setuptools version

setuptools==60.7.0

Python version

3.9

OS

Debian 11

Additional environment information

No response

Description

FileNotFoundError when importing pkg_resources

  File "/home/aaa/env/lib/python3.9/site-packages/google/api_core/client_info.py", line 23, in <module>
    import pkg_resources
  File "/tmp/aaa/pypi__setuptools/pkg_resources/__init__.py", line 74, in <module>
    from pkg_resources.extern.jaraco.text import (
  File "/tmp/aaa/pypi__setuptools/pkg_resources/_vendor/jaraco/text/__init__.py", line 227, in <module>
    lorem_ipsum: str = files(__name__).joinpath('Lorem ipsum.txt').read_text()
  File "/home/aaa/.pyenv/versions/3.9.7/lib/python3.9/pathlib.py", line 1266, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/home/aaa/.pyenv/versions/3.9.7/lib/python3.9/pathlib.py", line 1252, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/home/aaa/.pyenv/versions/3.9.7/lib/python3.9/pathlib.py", line 1120, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/aaa/py_deps/pypi__setuptools/pkg_resources/_vendor/jaraco/text/Lorem ipsum.txt'

Expected behavior

Pinning setuptools==60.6.0 in requirements.txt works fine. This issue started with setuptools==60.7.0.

How to Reproduce

Using Bazel and rules_python, build a zip executable using:

bazel build //<target> --output_groups=python_zip_file
python3 bazel-bin/<target>/<target>.zip 

Output

...
  File "/home/aaa/env/lib/python3.9/site-packages/google/api_core/client_info.py", line 23, in <module>
    import pkg_resources
  File "/tmp/aaa/pypi__setuptools/pkg_resources/__init__.py", line 74, in <module>
    from pkg_resources.extern.jaraco.text import (
  File "/tmp/aaa/pypi__setuptools/pkg_resources/_vendor/jaraco/text/__init__.py", line 227, in <module>
    lorem_ipsum: str = files(__name__).joinpath('Lorem ipsum.txt').read_text()
  File "/home/aaa/.pyenv/versions/3.9.7/lib/python3.9/pathlib.py", line 1266, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/home/aaa/.pyenv/versions/3.9.7/lib/python3.9/pathlib.py", line 1252, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/home/aaa/.pyenv/versions/3.9.7/lib/python3.9/pathlib.py", line 1120, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/aaa/py_deps/pypi__setuptools/pkg_resources/_vendor/jaraco/text/Lorem ipsum.txt'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
abravalhericommented, Feb 2, 2022

Thank you very much for the investigation @edward-watson-oxb !

Would you (or any other member of the community) be interested in providing a PR with the name change to https://github.com/jaraco/jaraco.text? (As a temporary workaround for the bazel limitation)

I think that if the reasons are well explained, the upstream project has good chances of accepting it… Otherwise I am afraid that the fix will have to come from the bazel side…

2reactions
edward-watson-oxbcommented, Feb 2, 2022

This is linked to the issue that Bazel does not play nicely with spaces in file names.

I’ve just been bitten with this whilst using a Poetry rule from Bazel, with no way to pin the setuptools version that I can find right now. So much for my deterministic build!

I’ve confirmed that renaming the file to use an underscore allows Bazel to symlink it into the runfiles just fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pyinstaller: FileNotFoundError: 'Lorem ipsum.txt' resource ...
The problem is that jaraco.text needed a hook file - a script which tells PyInstaller how to bundle packages properly.
Read more >
jaraco.text
This package provides handy routines for dealing with text, such as wrapping, substitution, trimming, stripping, prefix and suffix removal, ...
Read more >
https://mirrors.zju.edu.cn/opensuse/history/202001...
Added a workaround to the text editor for the bug in horizontal ... Rely on jaraco.collections for its case-insensitive dictionary support.
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