Skip to content
/ python-boilerplate Public template

A best-practices template project for Python modules

License

Notifications You must be signed in to change notification settings

BastiTee/python-boilerplate

Repository files navigation

python-boilerplate CI

A best-practices template project for Python modules

Setup

  • Create a new repository using this template.
  • Make sure that python is installed and available on system path. I strongly recommend using pyenv. Python 2 is not supported. It's end of life was on January 1st, 2020.
  • Make sure poetry is installed. This usually just means python -m pip install poetry.
  • Rename the project using the provided script: ./rename_template.sh.
  • Run make to initialize the project configuration and build everything.
  • Refer to the Makefile to learn about the various operations available. Most of them are just facades for poetry.

Features

  • Basic project/module organization according to https://packaging.python.org
  • Makefile bootstrapping script
  • poetry with virtual environments and project builds
  • black code formatting
  • Unit testing with pytest
  • Linting (flake8) and code formatting (autopep8) support
  • isort support for automated import sorting
  • mpyp support for type checking
  • Publishing to PyPi.org
  • vscode editor configuration including plugin recommendations, debugging support, unit test discovery and on-save formatting
  • Github actions continuous integration with multi-python testing
  • Executable script so after package installation you can run from the CLI using my_module_cli

Resources

Future ideas and todos

  • Embed flake8 config into pyproject.toml once they support it (see)
  • Use cookiecutter instead of shell script (it does work fine at the moment though)

Licensing

This project is licensed under Apache License 2.0.