sharedlib
Pythonic way for use "shared" folder of packages (utils).
Usage
First, we need to import “sharedlib” into the file where we will use the shared packages:
import sharedlib
Then import a “shared” package with the same name as specified in the config settings:
import my_shared_pkg
from my_shared_pkg import a, b, c
from my_shared_pkg.a.b.c import d
And it's working! Python registers a package with the specified name and you can use that in your files.
A complete example:
# file: service1/routes/admin.py
import sharedlib
# file: service2/models/user.py
import sharedlib
# original folder: custom_shared/
import my_shared_pkg
# original folders: custom_shared/a, custom_shared/b, custom_shared/c
from my_shared_pkg import a, b, c
# original folder: custom_shared/a/b/c, file: d.py
from my_shared_pkg.a.b.c import d
print(a, b, c, d)
Configuration file
sharedlib.ini
To work with “sharedlib” it is necessary to specify the file sharedlib.ini in the root of the project (repository):
[sharedlib]
folder_name = custom_shared
import_name = my_shared_pkg
If the file is not found, an exception will be raised.
Important: The configuration file must be located in the root of the project. Otherwise imports will not work properly.
pyproject.toml
You can also use pyproject.toml for customization:
[tool.sharedlib]
folder_name = "custom_shared"
import_name = "my_shared_pkg"
Metadata
Release files for sharedlib 0.0.1
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 | Actions |
|---|---|---|---|---|
| sharedlib-0.0.1.tar.gz | 3.8 kB | Without provenance | Details for sharedlib-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sharedlib-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for sharedlib-0.0.1-py3-none-any.whl |
Total release size: 8.8 kB
Security for sharedlib 0.0.1
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.