Test Python library
Project description
Py Lib Template
A Python library template with modern packaging setup for PyPI publishing.
Create your own libraries in the lib folder, using the py_lib_template example, you can create your own library by changing the name of the folder and update the folder name in the pyproject.toml file. Follow the steps below for more details
Installation
pip install py-lib-template
Usage
Basic Addition
from lib import add
# Add two numbers
result = add(1, 2)
print(result) # 3
# Works with floats too
result = add(1.5, 2.5)
print(result) # 4.0
Adding Multiple Numbers
from lib import add_many
# Add multiple numbers
result = add_many(1, 2, 3, 4, 5)
print(result.value) # 15
print(result.operands) # [1, 2, 3, 4, 5]
Development
Setup
# Create virtual environment
python -m venv venv
# Activate (Windows)
venv\Scripts\activate
# Activate (Unix/Mac)
source venv/bin/activate
# Install in development mode
pip install
pip install build
pip install twine
Pre-Build
- In pyproject.toml. Update the version and name of the library that you wish to publish.
Build
# Build the package
python build_lib.py
# Or manually
python -m build --outdir pypi_publish
Test
pytest
Lint & Format
# Format code
black lib tests
# Lint
ruff lib tests
# Type check
mypy lib
Publish
# Build first
python build_lib.py
# Publish to PyPI (requires credentials)
cd pypi_publish
python -m twine upload *
Project Structure
lib/
├── py_lib_template/ # Library source code
│ ├── __init__.py # Package entry point
│ └── math_utils.py # Example module
├── pypi_publish/ # Build artifacts (wheel, sdist)
├── tests/ # Test files
├── pyproject.toml # Package configuration
└── README.md
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file regex_str_checker_test-0.1.1.tar.gz.
File metadata
- Download URL: regex_str_checker_test-0.1.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bc7ab3aba977622f122c620b3dae36dddbf444fbf32330bbe3057911d9be739
|
|
| MD5 |
dfc605fe238d94f095213b575475e502
|
|
| BLAKE2b-256 |
d7e1d7d8316777de4171b7ae0234532674f03331450f45a9f7f65f729584dd2b
|
File details
Details for the file regex_str_checker_test-0.1.1-py3-none-any.whl.
File metadata
- Download URL: regex_str_checker_test-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fd9e7ad58fc067e88ddcf7fa781004715e224e83a2faa41d9c2bdec46487284
|
|
| MD5 |
133af09e91775560e0d6c4267aaf4b7f
|
|
| BLAKE2b-256 |
9fac1e256e301365f0d2eddc2a31765f88565e89a7ea8f034f3764e04607cb5c
|