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 onmain
- auto creating a new tag on push on
main
, sync versions - run
tests
andlint
ondev
andmain
when a PR is open
- auto publish to
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!
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
ruff check
ruff format
Tests inside /tests
are run using pytest
on PR both on dev
and main
In order to publish to pypi you need to create a secret called UV_PUBLISH_TOKEN
with your pypi access token under API tokens.
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