A Python library template for Starforge projects
Project description
Starforge Python Library Template
A production-ready Python library template for Starforge projects. This template provides a complete foundation for building, testing, and publishing Python libraries with modern tooling and best practices.
๐ Features
- Modern Python Packaging: Uses
pyproject.tomlfor configuration - Comprehensive Testing: Supports both unittest and pytest
- Code Quality: Integrated pylint, coverage, and formatting tools
- CI/CD Pipeline: GitHub Actions workflows for testing and publishing
- Documentation Ready: Sphinx configuration for professional docs
- CLI Support: Built-in command-line interface functionality
- Type Hints: Full type annotation support
- Professional Structure: Follows Python packaging best practices
๐ฆ Quick Start
Installation
# Clone the template
git clone <repository-url>
cd python-library-template
# Install in development mode
pip install -e ".[dev]"
# Or install with all dependencies
make install-dev
Usage
from starforge_library_template import HelloWorld
# Basic usage
greeter = HelloWorld()
print(greeter.greet()) # Output: Hello
# Personalized greeting
print(greeter.greet_with_name("Python")) # Output: Hello, Python!
Command Line Interface
# Run the CLI
python -m starforge_library_template
# Or if installed
starforge_library_template
๐ ๏ธ Development
Setup Development Environment
# Install development dependencies
make install-dev
# Run tests
make test
# Run tests with coverage
make test-cov
# Run linting
make lint
# Build package
make build
Available Commands
| Command | Description |
|---|---|
make install |
Install package in development mode |
make install-dev |
Install with development dependencies |
make test |
Run test suite |
make test-cov |
Run tests with coverage report |
make lint |
Run pylint code quality checks |
make clean |
Clean build artifacts |
make build |
Build package for distribution |
make check-dist |
Check distribution files |
make demo |
Run CLI demo |
๐งช Testing
The template includes comprehensive testing setup:
# Run with unittest
python -m unittest discover tests/ -v
# Run with pytest
python -m pytest tests/ -v
# Run with coverage
python -m coverage run -m unittest discover tests/ -v
python -m coverage report
๐ Project Structure
python-library-template/
โโโ .github/
โ โโโ workflows/ # GitHub Actions CI/CD
โโโ starforge_library_template/
โ โโโ __init__.py # Package initialization
โ โโโ __main__.py # CLI entry point
โ โโโ hello_world.py # Example library code
โโโ tests/
โ โโโ test_hello_world.py # Unit tests
โ โโโ test-requirements.txt
โโโ pyproject.toml # Modern Python configuration
โโโ Makefile # Development commands
โโโ MANIFEST.in # Package manifest
โโโ README.md # This file
๐ง Configuration
Package Configuration
The template uses pyproject.toml for all configuration:
- Package metadata: Name, version, description, authors
- Dependencies: Core and development dependencies
- Build system: Modern setuptools configuration
- Tool configuration: Pylint, coverage, pytest settings
GitHub Actions
- Pull Request Checks: Automated testing and linting on PRs
- Publishing: Automated PyPI publishing on releases
- Modular Workflows: Reusable workflow components
๐ Documentation
Building Documentation
# Install documentation dependencies
pip install sphinx sphinx-rtd-theme
# Build documentation
sphinx-build -b html docs/ docs/_build/html
Code Documentation
The template follows Google-style docstrings:
def greet_with_name(self, name: str) -> str:
"""
Return a personalized greeting message.
Args:
name (str): The name to include in the greeting.
Returns:
str: A personalized greeting message.
"""
return f'Hello, {name}!'
๐ Publishing
PyPI Publishing
- Create a release on GitHub
- Set up PyPI credentials in repository secrets:
PYPI_API_TOKEN: Your PyPI API token
- Publishing happens automatically via GitHub Actions
Manual Publishing
# Build package
make build
# Check distribution
make check-dist
# Upload to PyPI
make upload-pypi
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass and code quality checks
- Submit a pull request
๐ License
This project is licensed under the terms specified in the LICENSE file.
๐๏ธ Using as a Template
To use this template for a new project:
- Clone this repository
- Update package information in
pyproject.toml - Replace example code in
starforge_library_template/ - Update tests in
tests/ - Customize workflows in
.github/workflows/ - Update this README with your project details
๐ Links
- Homepage: GitHub Repository
- Documentation: Read the Docs
- Issues: Bug Tracker
Built with โค๏ธ for the Starforge ecosystem
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 starforge_python_library_template-1.0.3.tar.gz.
File metadata
- Download URL: starforge_python_library_template-1.0.3.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00e0ed9f8549bb195d9c87740d6931c12b138ac7be870dc6e5a8bd88e9e17a44
|
|
| MD5 |
fa29c3155528ac04ef895d12967b8887
|
|
| BLAKE2b-256 |
ca50b68af79037020df51e3149ac529ffbe985d6f7ca09ded559b09c78a929d0
|
File details
Details for the file starforge_python_library_template-1.0.3-py3-none-any.whl.
File metadata
- Download URL: starforge_python_library_template-1.0.3-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d84d81570059c7a80af5e320de06e89d52eb8caabc34bfe605155bd18dfda559
|
|
| MD5 |
2d61326ea5d3bce3bd9d4686ef45e910
|
|
| BLAKE2b-256 |
835b8c1b85242a71a045c84c32ae619672f6d7df386d309544449fe8d426bbf9
|