Skip to content

febus982/bootstrap-python-package

Repository files navigation

bootstrap-python-package

Stable Version stability-beta

Python 3.8 Python 3.9 Python 3.10 Python 3.11 Python 3.12

Maintainability Test Coverage Checked with mypy Code style: black Ruff

This template repository provides the boilerplate to create a python package. It is configured with all the following features:

  • Test suite using pytest
  • Typing using mypy
  • Linting using ruff
  • Code formatter using black
  • Integration with CodeClimate for code quality and coverage checks
  • CI pipeline supporting:
    • testing against multiple python versions
    • releases on PyPI
    • GitHub pages documentation using mkdocs

This project doesn't currently use tox or other matrix testing utilities. I prefer to run the tests only against the latest python locally, and run previous python versions directly in the CI pipeline to catch these bugs.

How to use this repository template to create a new package

IMPORTANT: The repository is configured to deploy on the test PyPI repository. It's strongly recommended to create the project in the test PyPI repository and test the deployment pipeline. When you're happy with the result, create the project on the official PyPI repository and remove the marked lines in workflows/release.yml.

Package release

This setup uses poetry-dynamic-versioning. This means it's not necessary to commit the version in the code but the CI pipeline will infer it from the git tag.

To release a new version, just create a new release in the github repository. It will create a new tag and do all the magic.

IMPORTANT: The default configuration requires the release name and the tag to follow the convention vX.X.X (semantic versioning preceded by lowercase v). It will publish the correct version on Pypi, omitting the v (ie. v1.0.0 will publish 1.0.0).

This format can be customized, refer to poetry-dynamic-versioning docs

Commands for development

All the common commands used during development can be run using make targets:

  • make dev-dependencies: Install dev requirements
  • make test: Run test suite
  • make check: Run tests, code style and lint checks
  • make fix: Run code style and lint automatic fixes (where possible)
  • make docs: Render the mkdocs website locally