Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analyzing Kaitai Structs fails on missing 'pkg_ressources' python module #156

Open
derVedro opened this issue Nov 26, 2022 · 3 comments
Open

Comments

@derVedro
Copy link

If your system python is not 3.9 you're pretty screwed on analizing Kaitai Structs:

Python stderr:
Traceback (most recent call last):
  File "/tmp/HobbitsPythonrBHuvX/thescript.py", line 162, in parse_data
    struct_module = importlib.__import__(package_name, fromlist=[class_name])
  File "<frozen importlib._bootstrap>", line 1109, in __import__
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/tmp/hobbits-GGgAzl/png.py", line 3, in <module>
    from pkg_resources import parse_version
ModuleNotFoundError: No module named 'pkg_resources'
@derVedro
Copy link
Author

You can hack around and install pip (which comes with setuptools and pkg_resources) into your hobbits-cpython directory tree.

First get the pip installer script into your temp directory:
$ wget https://bootstrap.pypa.io/get-pip.py -P /tmp

Then install pip into your hobbits-cpython
$ hobbits-cpython/bin/python3.9 /tmp/get-pip.py

The requeired packages are in hobbits-cpython/lib/python3.9/site-packages now, so you're done.

@hello-adam
Copy link
Member

yeah, looks like the built-in python pip is messed up in some of the builds :( ugh

Thanks for posting the workaround! I might just put something like that in the build steps because building Python reliably with that stuff seemed weirdly error-prone in the CI I had set up.

@generalmimon
Copy link

BTW, Python parsers generated by Kaitai Struct compiler v0.10 do not import pkg_resources anymore, see Kaitai Struct v0.10 release notes:

  • Notable improvements:
    • (...)
    • Python: generated parsers no longer import pkg_resources, which caused performance and usability issues (#804) — the runtime library API version check now compares tuples instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants