Skip to main content

Template for new Python projects.

Project description

PythonTemplateIt

Category Status and Links
General
CD/CI
PyPI
GitHub

Short description

PythonTemplateIt is a reusable template for Python projects with standardized packaging, linting, testing, environment bootstrapping, and GitHub workflow automation.


Module Overview

Key Features

  • Poetry-based project packaging and dependency management.
  • Published package layout rooted under src/pti/ for template imports such as import pti.pythontemplateit.
  • Pre-configured quality tooling (black, isort, flake8, pytest, pre-commit).
  • PowerShell and shell scripts for Python setup, optional React setup, private repository access, and Docker-assisted database provisioning.
  • Dependabot automation for Poetry dependencies, GitHub Actions workflows, and Docker image updates.
  • Local Docker workflows provision MySQL and Redis services with health checks for template-based projects that need backing services.
  • Reusable CI/CD workflows for pull request validation and post-merge release/publish handling.
  • Release note and versioning conventions aligned to SemVer.

Project Structure

  • src/pti/: Template Python package source used by the published distribution.
  • src/: Application modules and package source code.
  • tests/: Unit and functional test suites with fixtures and test data.
  • scripts/: SQL/bootstrap assets.
  • docker-compose.yaml: Local MySQL and Redis service definitions for development and end-to-end environments.
  • legacy/: Archived or excluded legacy resources.
  • *.ps1: Setup and automation scripts for environment and toolchain tasks.

Getting Started

Prerequisites

  • Python 3.12+
  • Poetry
  • Docker (optional, for local MySQL and Redis services)
  • GitHub access token(s) for private package sources when needed

Setup

# 1) Generate .env from the SetupDotEnv script
.\SetupDotEnv.ps1

# 2) Configure private repository access for Poetry
.\SetupPrivateRepoAccess.ps1

# 3) Install Python tooling and project dependencies
.\InstallPy.ps1

# 4) Optional: configure GitHub CLI access
.\SetupGitHubAccess.ps1

# 5) Refresh development dependencies directly when needed
.\InstallDevEnv.ps1

# 6) Optional: start the local service stack
.\SetUpDocker.ps1
# or
# docker compose up -d db

# 7) Run tests
poetry run pytest

Optional Frontend Bootstrap

# Use these only in repos that also contain a Node/React app
.\InstallReact.ps1
# or
bash ./install_react.sh

Common Commands

poetry install
poetry run pytest
poetry run pytest --cov=src --cov=tests --cov-report=term-missing
poetry run black src tests
poetry run isort src tests
poetry run flake8 src tests
poetry run pre-commit run --all-files

Automation Scripts

  • InstallPy.ps1: Bootstraps Poetry tooling, updates the repository remote when credentials are available, and installs Python dependencies.
  • InstallDevEnv.ps1: Installs development dependencies and configures pre-commit tooling.
  • InstallReact.ps1: Installs Node dependencies for React projects on Windows and configures pre-commit when available.
  • install_react.sh: Bash equivalent of the React installer for non-PowerShell environments.
  • SetupDotEnv.ps1: Generates .env values from environment variables.
  • SetupPrivateRepoAccess.ps1: Configures private package source credentials.
  • SetupGitHubAccess.ps1: Configures GitHub authentication for local automation.
  • SetUpDocker.ps1: Recreates the local compose stack in detached mode and is intended for workflows where resetting local database state is acceptable.
  • CreateDbSqlScript.ps1: Generates SQL bootstrap scripts for MySQL setup.

Active Workflows

  • .github/workflows/py-temp-pr-pub-no_docker-def.yaml: Pull request validation workflow.
  • .github/workflows/py-temp-publish-pub-build_release_notify_after_merge-def.yaml: Release build, publish, and notification workflow after merge to master, excluding Dependabot-triggered merges.
  • .github/dependabot.yaml: Automated dependency update checks for Poetry packages, GitHub Actions workflows, and Docker assets.

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

pythontemplateit-0.8.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

pythontemplateit-0.8.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pythontemplateit-0.8.0.tar.gz.

File metadata

  • Download URL: pythontemplateit-0.8.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.12 Linux/6.17.0-1008-azure

File hashes

Hashes for pythontemplateit-0.8.0.tar.gz
Algorithm Hash digest
SHA256 53bc35c69f3860a05a5e92d761ab5ff67b296d5dd7ce3567e8c8fecb6352ae5b
MD5 8fe2dcc996cf5a09e096573f185465e5
BLAKE2b-256 717dccbac0b8a721927d2ec99fdd79c85218c71e68ffb03d353bf071d5eb617a

See more details on using hashes here.

File details

Details for the file pythontemplateit-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: pythontemplateit-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.12 Linux/6.17.0-1008-azure

File hashes

Hashes for pythontemplateit-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69e446f1dca5873134ae45d16ee2dd73d59522d04373657c79e70d68b5f8b4b0
MD5 888cba09431c22bef3b45cba3da31a8f
BLAKE2b-256 fc51453fded4acac43d364277c7fe41c373df18977d60c3723c5729f8c77147b

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