This project shows how to package data files within a Python distribution, and has some example code for reading the data files. To build this distribution, create a venv with setuptools, wheel, and pep517 installed, then execute the latter as a module:
python -m pep517.build .
The distributions (an sdist .tar.gz and a bdist .whl) will be written to ./dist/ subdirectory. To test it out, install the distribution and run the console script resources-example.
Here’s a compatibility summary of the five approaches demonstrated:
Module |
Description |
In stdlib? |
Works on Py2? |
Works on Py3? |
Works in zipfile? |
|---|---|---|---|---|---|
example1.py |
os.path.join |
yes |
yes |
yes |
no |
example2.py |
pkgutil |
yes |
yes |
yes |
yes |
example3.py |
pkg_resources |
no |
yes |
yes |
yes |
example4.py |
importlib.resources |
yes |
no |
yes (3.7+) |
yes |
example5.py |
importlib_resources |
no |
yes |
yes |
yes |
If you are interested in creating an executable zip from source, you can use stdlib zipapp utility (Python 3.5+):
python3 -m zipapp --compress /path/to/resources-example --main="myapp:main" --output=myapp.zip
And now you can run the zip directly with the interpreter (any Python version):
python myapp.zip
Metadata
Release files for resources-example 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| resources-example-0.2.tar.gz | 4.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| resources_example-0.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 10.5 kB
Release files / resources-example-0.2.tar.gz
| Download URL | resources-example-0.2.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2308f460c40de7ce5bb200f65d11e98fd547e1ae45d4480cf63110450b11e5d8
|
|
BLAKE2b-256 checksum How to use checksums |
34c4a6c9e13313c5d6806729feeebfff9e0c696f49f84522fbbbca5c5e20f507
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3
|
Release files / resources_example-0.2-py2.py3-none-any.whl
| Download URL | resources_example-0.2-py2.py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
8171bbd50ffbb694f5e86d198fd556f8fd66c2a2537cd46e9406105119949418
|
|
BLAKE2b-256 checksum How to use checksums |
eb6f3414bcf5bb8fbe1c9c5b27e91cec9cc43199b8b503f0d987918e1f1a7c9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3
|
Security for resources-example 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.