python-repo-template

githubactions codecov CodeQL SecretsScan

This is a template repository that you can use to quickly create a python application that can be built, tested, and released as an internal python module.

Support Python 3.9, 3.10, 3.11, 3.12.

Use

Setting up a new repository from this template

Create a directory and pull all the files in this template.

mkdir new_repo_name
cd new_repo_name
git init
git pull https://github.com/kyhau/python-repo-template

Create virtual env and install dependencies

Linux

virtualenv -p python3.11 env
. env/bin/activate
pip install -e .

Windows

virtualenv -p C:\Python310\python.exe env
env\Scripts\activate
pip install -e .

Run Black, then run pytest, codecov, mypy and flake8 with Tox

pip install -r requirements-build.txt

# Autoformat code following most of the rules in PEP 8
black --line-length=99 module/

# Run pytest, codecov, mypy and flake8 with Tox
tox -r

Version-bump your application or module with bump2version

Examples

# e.g. 1.2.3.dev0 -> 1.2.3
bumpversion --allow-dirty --commit --tag release

# e.g. 1.2.3 -> 1.2.4.dev0
bumpversion --commit patch

# e.g. 1.2.3.dev0 -> 2.0.0.dev0
bumpversion --commit major

# e.g. 1.2.3.dev0 -> 1.3.0.dev0
bumpversion --commit minor

# e.g. 1.2.3.dev0 -> 1.2.4.dev0
bumpversion --commit patch

# e.g. 1.2.3.dev0 -> 1.2.3.dev1
bumpversion --commit dev

# e.g. 1.2.3.dev0 -> 1.2.3
bumpversion --dry-run --list release