Skip to main content

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"

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)

Source distribution for sharedlib 0.0.1
File Size Uploaded
sharedlib-0.0.1.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sharedlib 0.0.1
File Interpreter ABI Platform
sharedlib-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / sharedlib-0.0.1.tar.gz

Download URL sharedlib-0.0.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
410b790987c348269bac9a5df297da8886316234745b37d6d82f6e8074141709
BLAKE2b-256 checksum
How to use checksums
bb815cb485d60a182949a0d419bb053a1060f3ef034c7d39d1c94302974bd0ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.18

Release files / sharedlib-0.0.1-py3-none-any.whl

Download URL sharedlib-0.0.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9ca44fed807ac7a09b1c1f5b8cbf7456f399ec5b327cf61a62e460d8723db66
BLAKE2b-256 checksum
How to use checksums
0d0ae1cec8f2b0ed155f821a998585371014e1e1063e01d0da801d3c84cd7a9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.18

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page