Platform Base Library
platform_base_lib is a Python library designed as a foundational component for managing project infrastructure using gRPC protocol buffers. This project simplifies and standardizes common tasks such as communication setup, protobuf compilation, and offering shared functionalities for base setup.
Table of Contents
Features
- gRPC Support: Automatically compile
.protofiles to Python bindings for gRPC services (*_pb2.pyand*_pb2_grpc.py). - Declarative Configuration: Simplifies package setup using
setup.cfgand supports easy installation and dependency management. - Extensible: Provides functionality to build on top of existing gRPC infrastructure.
Getting Started
Prerequisites
Ensure you have the following installed:
- Python >= 3.12
- Pip >= 20.x.x
- Build tools for Python packaging:
pip install -r requirements.txt
If you're working with the gRPC protocol buffers, you’ll also need:
grpcioandgrpcio-toolsfor protocol buffer compilation.
Installation
Install From Git
You can install the platform_base_lib directly from the source repository:
pip install git+https://github.com/KJBNAgtechPlatform/PlatformBaseLib.git@main#egg=platform_base_lib
Install From PyPI
To install the library from PyPI (after publishing):
pip install platform_base_lib
Project Commands Cheatsheet
Protobuf File Compilation
Run the custom generate_protos command to compile .proto files into Python bindings:
python setup.py generate_protos
Package Building
To generate source (.tar.gz) and wheel (.whl) distributions:
python setup.py sdist bdist_wheel
The distribution files will be located in the dist/ folder.
Codebase Walkthrough
1. Repository Structure
platform_base_lib/
├── .env # Environment variables configuration
├── .gitignore
├── README.md # Project documentation
├── requirements.txt # Project dependencies
├── main.py # Entry Point
├── docker-compose.yml # Docker services configuration
│
├── base_lib/ # Main package directory
│ ├── __init__.py
│ │
│ ├── configs/ # Configuration management
│ │ ├── __init__.py
│ │ └── config.py # Settings and environment configuration
│ │
│ ├── infra/ # Infrastructure layer
│ │ ├── __init__.py
│ │ ├── grpc/ # gRPC related code
│ │ │ ├── __init__.py
│ │ │ ├── proto/ # Protocol buffer definitions (git submodule)
│ │ │ └── clients/ # gRPC client implementations
│ │ │
│ │ └── db/ # Database related code
│ │ ├── __init__.py
│ │ ├── mysql/ # MySQL specific implementations
│ │ └── redis/ # Redis specific implementations
│ │
│ ├── domain/ # Business logic layer
│ │ ├── __init__.py
│ │ ├── entities/ # Business entities
│ │ └── use_cases/ # Business use cases
│ │
│ ├── app/ # Application layer
│ │ ├── __init__.py
│ │ ├── services/ # Service orchestration
│ │ ├── api/ # API definitions
│ │ └── tasks/ # Background tasks
│ │
│ └── interfaces/ # Interface definitions
│ ├── __init__.py
│ ├── interactor/ # Interface implementations
│ └── db_model/ # Database models
│
├── tests/ # Test directory
│ ├── __init__.py
│ ├── unit/ # Unit tests
│ ├── integration/ # Integration tests
│ └── conftest.py # Test configurations
│
├── docs/ # Documentation
│ └── api/ # API documentation
│
└── db-data/ # Database volume mount point (git-ignored)
├── mysql/ # MySQL data
└── test-db-data/ # Test database data
2. Key Components
Protobuf Management
All .proto files are stored git submodule under base_lib/infra/grpc/proto/. These files define gRPC services and message types.
git repo https://github.com/KJBNAgtechPlatform/protos
Example Usage:
from platform_base_lib.infra.grpc.proto import auth_pb2, auth_pb2_grpc
class MyAuthService(auth_pb2_grpc.AuthServiceServicer):
def Login(self, request, context):
# Process login requests
return auth_pb2.LoginResponse(success=True)
Dependencies
Listed in requirements.txt, and must be installed for the package to work:
grpcio==1.56.2
grpcio-tools==1.56.2
pytest==7.4.2
numpy==1.25.0
pandas==2.1.0
For development dependencies, use:
pip install -e .[dev]
Usage
-
Clone the Repository:
git clone https://github.com/KJBNAgtechPlatform/PlatformBaseLib.git cd PlatformBaseLib
-
Install Dependencies:
pip install -r requirements.txt
-
Compile
.protoFiles:python setup.py generate_protos
-
Build and Distribute the Package:
python setup.py sdist bdist_wheel
-
Use the Package in Another Project: Install the wheel (
.whl) file or use Git for installation:pip install git+https://github.com/KJBNAgtechPlatform/PlatformBaseLib.git@main#egg=platform_base_lib
License
This library is licensed under the MIT License. See LICENSE for details.
Metadata
Release files for platform-base-lib 0.1.6
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 |
|---|---|---|---|---|
| platform_base_lib-0.1.6.tar.gz | 20.1 kB | Without provenance | Details for platform_base_lib-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| platform_base_lib-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for platform_base_lib-0.1.6-py3-none-any.whl |
Total release size: 44.8 kB
Release files / platform_base_lib-0.1.6.tar.gz
| Download URL | platform_base_lib-0.1.6.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41eadea652fb85441bda76b231f304f041b3201eb0da1db4fbe68320b74362c8
|
|
BLAKE2b-256 checksum How to use checksums |
0a3674a7c376bd48d27e6de603c36a3ef0b3825feec7848385dcfb222ddea0f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / platform_base_lib-0.1.6-py3-none-any.whl
| Download URL | platform_base_lib-0.1.6-py3-none-any.whl |
|---|---|
| Size | 24.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b490c6ab480dc0c87e2cf29b7c72f30c8c15c59d29c1e7154d3b28a25b19c234
|
|
BLAKE2b-256 checksum How to use checksums |
4304502a77cd724c9c7af90cd75a873206196024ce13e07f010cd4743c768798
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Security for platform-base-lib 0.1.6
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.