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

Use pkgutil.get_data for zip-safe resource loading #88

Closed

Conversation

sinoroc
Copy link

@sinoroc sinoroc commented Sep 26, 2020

When running from a Zip file (zipapp, *.pyz), loading resources
from package data can not be done by directly reading files relative
to __file__, since there is no valid path on the file system for
zipped files.

Using pkgutil.get_data ensures that loading files from a Zip archive
is handled accordingly.

Resolves: python-poetry/poetry#2965

@sinoroc sinoroc force-pushed the zip-safe-loading-of-package-data branch from c2d8022 to 1a99dd3 Compare September 26, 2020 17:39
When running from a Zip file (`zipapp`, `*.pyz`), loading resources
from package data can not be done by directly reading files relative
to `__file__`, since there is no valid path on the file system for
zipped files.

Using `pkgutil.get_data` ensures that loading files from a Zip archive
is handled accordingly.

Resolves: python-poetry/poetry#2965
@sinoroc sinoroc force-pushed the zip-safe-loading-of-package-data branch from 1a99dd3 to 9f34a86 Compare September 26, 2020 18:32
@neersighted
Copy link
Member

Closing for now as importlib_resources would be the way to go here.

@neersighted neersighted closed this Oct 5, 2022
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

Successfully merging this pull request may close these issues.

Can not load package data resources when running in a zipapp
2 participants