Metadata-Version: 2.1
Name: sharedlib
Version: 0.0.1
Summary: Share packages for monorepo services
License: MIT License
        
        Copyright (c) 2024 Pavel Kutsenko
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/paqstd-dev/sharedlib
Project-URL: Bug Tracker, https://github.com/paqstd-dev/sharedlib/issues
Keywords: monorepo,shared,sharedlib,lib,repo
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE

# 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: 

```py
import sharedlib
```

Then import a “shared” package with the same name as specified in the config settings:

```py
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: 

```py
# 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):

```ini
[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:

```toml
[tool.sharedlib]
folder_name = "custom_shared"
import_name = "my_shared_pkg"
```
