A simple example package for demonstrating Python packaging
Project description
Example Package
A simple Python package demonstrating modern packaging practices with pyproject.toml (PEP 621).
Features
- 🧮 Calculator Module: Basic arithmetic operations (add, subtract, multiply, divide)
- 🛠️ Utility Functions: Helper functions for formatting results
- 🖥️ CLI Tool: Command-line interface for quick calculations
- ✅ Well Tested: 100% test coverage with pytest
- 📦 Modern Packaging: Uses pyproject.toml standard
Installation
From Source
# Clone the repository
git clone https://github.com/yourusername/example-package.git
cd example-package
# Install in development mode
pip install -e .
# Or install with development dependencies
pip install -e ".[dev]"
From PyPI (once published)
pip install example-package
Usage
As a Library
from example_package.core import Calculator
from example_package.utils import format_result
# Create calculator instance
calc = Calculator()
# Perform calculations
result = calc.add(5, 3)
print(result) # Output: 8
result = calc.multiply(4, 7)
print(format_result(result)) # Output: Result: 28
Command-Line Interface
# Addition
example-calc add 10 5
# Output: Result: 15
# Subtraction
example-calc subtract 20 8
# Output: Result: 12
# Multiplication
example-calc multiply 6 7
# Output: Result: 42
# Division
example-calc divide 15 3
# Output: Result: 5.0
Development
Running Tests
# Run all tests
pytest
# Run with coverage report
pytest --cov=example_package --cov-report=term-missing
# Run specific test file
pytest tests/test_core.py -v
Code Quality
# Format code with black
black src/ tests/
# Lint code with flake8
flake8 src/ tests/
# Type checking with mypy
mypy src/
Building the Package
# Install build tools
pip install build
# Build distribution packages
python -m build
# This creates:
# - dist/example_package-0.1.0-py3-none-any.whl
# - dist/example_package-0.1.0.tar.gz
Publishing to PyPI
# Install twine
pip install twine
# Upload to PyPI (requires account)
python -m twine upload dist/*
# Or upload to TestPyPI first
python -m twine upload --repository testpypi dist/*
Project Structure
python-package/
├── src/
│ └── example_package/
│ ├── __init__.py # Package initialization
│ ├── core.py # Calculator class
│ ├── utils.py # Utility functions
│ └── cli.py # CLI entry point
├── tests/
│ ├── __init__.py
│ └── test_core.py # Test suite
├── docs/
│ └── usage.md # Extended documentation
├── pyproject.toml # Package configuration
├── README.md # This file
├── LICENSE # MIT License
└── .gitignore # Git ignore rules
Requirements
- Python 3.7 or higher
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Links
- Homepage: https://github.com/yourusername/example-package
- Documentation: https://github.com/yourusername/example-package/blob/main/README.md
- Bug Reports: https://github.com/yourusername/example-package/issues
Author
Your Name (your.email@example.com)
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 example_package_prajesh-0.1.0.tar.gz.
File metadata
- Download URL: example_package_prajesh-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8d518d68cfe18691909c0587dd50d1f7dcdadc9c2718515524cde8b55741cbc
|
|
| MD5 |
83efaa27d3975c4193dcfd09c218796b
|
|
| BLAKE2b-256 |
0ae3b1af55d972cfcb34493b6028f0fbc9719e183c2d1b36d17d1fe90d3266de
|
File details
Details for the file example_package_prajesh-0.1.0-py3-none-any.whl.
File metadata
- Download URL: example_package_prajesh-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47546fa82445636322ac5c05f99acd6b376dec0c08a395e991d7a034c5e374dd
|
|
| MD5 |
4d271d9bd07421ac9e642d2e09cf9af3
|
|
| BLAKE2b-256 |
edeb804d5f743dd68a6b0958ec648bd0fef8bc247d3c9845873cff254d8989e8
|