Skip to main content

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.toml for 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

  1. Create a release on GitHub
  2. Set up PyPI credentials in repository secrets:
    • PYPI_API_TOKEN: Your PyPI API token
  3. Publishing happens automatically via GitHub Actions

Manual Publishing

# Build package
make build

# Check distribution
make check-dist

# Upload to PyPI
make upload-pypi

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass and code quality checks
  6. 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:

  1. Clone this repository
  2. Update package information in pyproject.toml
  3. Replace example code in starforge_library_template/
  4. Update tests in tests/
  5. Customize workflows in .github/workflows/
  6. Update this README with your project details

๐Ÿ”— Links


Built with โค๏ธ for the Starforge ecosystem

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starforge_python_library_template-1.0.3.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file starforge_python_library_template-1.0.3.tar.gz.

File metadata

File hashes

Hashes for starforge_python_library_template-1.0.3.tar.gz
Algorithm Hash digest
SHA256 00e0ed9f8549bb195d9c87740d6931c12b138ac7be870dc6e5a8bd88e9e17a44
MD5 fa29c3155528ac04ef895d12967b8887
BLAKE2b-256 ca50b68af79037020df51e3149ac529ffbe985d6f7ca09ded559b09c78a929d0

See more details on using hashes here.

File details

Details for the file starforge_python_library_template-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for starforge_python_library_template-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d84d81570059c7a80af5e320de06e89d52eb8caabc34bfe605155bd18dfda559
MD5 2d61326ea5d3bce3bd9d4686ef45e910
BLAKE2b-256 835b8c1b85242a71a045c84c32ae619672f6d7df386d309544449fe8d426bbf9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page