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

RFC: Python 3.7 package resources support #98

Merged
merged 8 commits into from
Sep 19, 2024

Conversation

shizmob
Copy link
Contributor

@shizmob shizmob commented Sep 17, 2024

This series of patches adds support for loading web resources through Python's importlib.resources abstraction, allowing them to be packed into whatever module loading mechanism is used (e.g. zipimport). This would allow distributing copyparty as a single .py without needing any kind of file system access in /tmp or elsewhere.

Three pending improvements that make it RFC for now:

  • Make package name used for access configurable through E instead of hardcoded in util.py
  • Verify walk_resources() correctness
  • Add support for the older pkg_resources API

@shizmob
Copy link
Contributor Author

shizmob commented Sep 17, 2024

Motivating example: attached is a version of copyparty (tar'd because GitHub, from the HEAD of my branch at time of writing, 2997c42) packed with a simple packer I wrote into a single .py file that doesn't need file system access other than for serving files.

copyparty.py.tar.gz

@9001
Copy link
Owner

9001 commented Sep 19, 2024

Nice! This will be great for the pyz / zipapp too, since that currently extracts the webdeps and jinja-templates into a temporary folder, which was somewhat problematic due to systemd's tmpfiles cleaner.

Thanks for the cool stuff 😁

@9001 9001 merged commit a462a64 into 9001:hovudstraum Sep 19, 2024
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.

2 participants