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.2.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.2.tar.gz.

File metadata

File hashes

Hashes for starforge_python_library_template-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6df20c6d5020eb2cb404b8aac0e3031696e5fade4e5184824b1d3a6d96d3c3cc
MD5 5e7bad0be4097f5fe9923296767826cb
BLAKE2b-256 4997db43170f7eb05f91768be1bc03cd20ab9711acb276aecb0434f8cbefa472

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for starforge_python_library_template-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d70b535f218393d42f51c3c610c1cc3f61af80282beab0d9575fdb1d0110443e
MD5 17351ef287ff33dedde0b80f6dec411e
BLAKE2b-256 a8754d27bad1f14982afd82d67a620957298e7123930a8bbdbc79a6ede0a93d5

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