Skip to main content

Python application template for personal use

Project description

pyprefab

A template-driven command line interface (CLI) that creates the scaffolding for a fully-functional, modern Python package. The goal of pyprefab is to get you straight to writing application code by handling project startup tasks like logging setup and creating a test harness.

The scaffolding includes:

  • project files in the src layout format
  • pyproject.toml with dependency groups
  • CHANGELOG.md, CONTRIBUTING.md, .gitignore, and README.md
  • automated package versioning with setuptools-scm
  • structlog-based pre-configured logging
  • a pytest-based test harness
  • a pre-commit configuration with common plugins like ruff for linting (optional)
  • GitHub workflow that automatically runs code checks, tests, and a test coverage report
  • GitHub workflows to publish the package to TestPyPI and PyPI

Quickstart

If you have uv installed, uv tool run is the fastest way to create a new Python package with pyprefab:

uvx pyprefab <name-of-new-package>

Otherwise, use pip or pipx to install pyprefab:

pip install pyprefab

pyprefab <name-of-new-package>

Details

pyprefab CLI

By design, pyprefab requires only a few pieces of information to create the boilerplate for a Python package.

โžœ pyprefab --help

  Usage: pyprefab [OPTIONS] NAME

 ๐Ÿ Create Python package boilerplate ๐Ÿ

โ•ญโ”€ Arguments โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ *    name      TEXT  Name of the project                                                                                      โ”‚
โ”‚                      [required]                                                                                               โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ•ญโ”€ Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ *  --author             TEXT  Project author                                                                                  โ”‚
โ”‚                               [required]                                                                                      โ”‚
โ”‚ *  --description        TEXT  Project description                                                                             โ”‚
โ”‚                               [required]                                                                                      โ”‚
โ”‚ *  --dir                PATH  Directory that will contain the project                                                         โ”‚
โ”‚                               [required]                                                                                      โ”‚
โ”‚    --help                     Show this message and exit.                                                                     โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

For example:

pyprefab project_test --author lassie --description "this is a pet project for lassie" --dir ~/code/lassie

If you don't explicitly pass the --author, --description, and --dir options, pyprefab will prompt you for them:

โžœ pyprefab project_test
Project author: lassie
Project description: this is a pet project for lassie
Project directory: /Users/dogs/code/lassie

Creating a dev environment for the new package

Follow the steps below to create a development environment for Python packages generated by pyprefab.

These directions use uv, but you can use your preferred tooling.

  1. cd to the directory of the new Python package

  2. Create a virtual environment and install the project dependencies:

    uv sync
    
  3. Test the project setupt:

    uv run <your_package_name>
    

    You should see a log output stating that the project has been set up correctly.

    For example: 2025-01-13 02:29:08 [info ] project_test successfully created.

    You can also run the tests:

    uv run pytest
    

Optional:

  • Add the new project to a git repository:

    git init
    git add .
    git commit -am "Initial commit"
    
  • If you use pre-commit, pyprefab's boilerplate includes a baseline pre-commit-config.yaml configuration. To use it, make sure the project has been added to git (see above) and run the following command to install the pre-commit git hook scripts:

    pre-commit install
    

Contributing to pyprefab

Please refer to CONTRIBUTING.md.

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

pyprefab-0.4.0.tar.gz (53.0 kB view details)

Uploaded Source

Built Distribution

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

pyprefab-0.4.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file pyprefab-0.4.0.tar.gz.

File metadata

  • Download URL: pyprefab-0.4.0.tar.gz
  • Upload date:
  • Size: 53.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyprefab-0.4.0.tar.gz
Algorithm Hash digest
SHA256 990a2dc709613a490b1857b9d9f4a7e6c56c3076d14a023726d49f16e583d07a
MD5 b0e87eeb3c668966e1c763e185353452
BLAKE2b-256 5bb888e19becfcff1c25c919fb88c98b2c50a9955ca8ca16cffa5bdfc284d2f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyprefab-0.4.0.tar.gz:

Publisher: publish-pypi.yaml on bsweger/pyprefab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyprefab-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pyprefab-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyprefab-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93b461a2d41bcd8c18a1becb096a0a80d544b32837d4998f665b2117c16421f4
MD5 19bf58969086f9b168391a1d45853eaf
BLAKE2b-256 09a21b155daa11c47ac815e27f2db809e125b81b19126c8cc16ffca2336ccda3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyprefab-0.4.0-py3-none-any.whl:

Publisher: publish-pypi.yaml on bsweger/pyprefab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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