Skip to content

FrancescoSaverioZuppichini/python-template

Repository files navigation

Python Template 🐍

PyPI version

A template for a python project for 2025

Features:

  • 🛠️ configuration in a single file pyproject.toml
  • 📦 uv as package manager
  • 💅 ruff for linting and formatting
  • 🧪 pytest
  • 🧹 Makefile with code quality checks
  • 📚 auto doc generation
  • 🐳 CI/CD Optimized Docker Image runs when a new release is created pushing to gh registry
  • 🦾 GitHub actions:
    • auto publish to pypi on push on main
    • auto creating a new tag on push on main, sync versions
    • run tests and lint on dev and main when a PR is open

Getting started

Installation

To set it up and run

uv venv
uv sync

Then

python main.py

Will output a random joke

Why did the cow in the pasture get promoted at work? ...  Because he is OUT-STANDING in his field!

Development

You can install in editable mode the library

uv pip install -e .

You can now run, for example, a function defined as scripts in the pyproject.toml

make_me_laugh

Linting

ruff check

Formatting

ruff format

CI/CD

Tests

Tests inside /tests are run using pytest on PR both on dev and main

Publish Package

In order to publish to pypi you need to create a secret called UV_PUBLISH_TOKEN with your pypi access token under API tokens.

Docker

Dockerfile contains a multi stage build that uses --compile-bytecode to compite your package. For this example, the resulting image is just

docker build -t python-template .
REPOSITORY        TAG       IMAGE ID       CREATED          SIZE
python-template   latest    1ded7d260b1c   58 seconds ago   55.4MB

The image is build using the build workflow when a new relaese is created