- Create the new project based on the template:
copier https://github.com/maces/copier-python-app.git <project_dir>
- Answer the questions
cd <project_dir>
- Make sure the correct Python version is used or
pyenv
is correctly installed: - Install the dependencies, which can take a while via
poetry install
- git setup
- Init git with
git init
- Add the new files with
git add * .gitignore .copier-answers.yml .env.sample .python-version
.copier-answers.yml
is needed for future updates from this template.env.sample
to provide sample configs, but never commit the.env
file!.python-version
if you want to pin the python version for all developers of the app
git commit -m "initial commit"
- Init git with
- Use the poetry environment
poetry shell
- Activate the git hook
inv install-hooks
- Now start developing :)
This template is based on poetry
which should be installed on your system, available in $PATH
. Poetry is choosen as it combines dependency and virtual environment management. More precissely dependecies are split into application dependecies and development dependecies (like pytest
) and primary dependecies and subdependecies. Additionally they can all be pinned in poery.lock
, which should be included in git!
For distribution an example docker file is included. The container can be build and run via the task runner.
Pytest for it's great features, ease of use and extensibility. - coverage show test coverage, with branch coverage activated
- MyPy for type checking
- Pylint to check for code smells
- Safety to check for vurnabilities in the dependecies
- Bandit to check for basic security issues in the code
- isort for sorting dependecies
- black to deterministically format the code with a strong opinion, so you do not have to have one and can focus on the project iteslf.
Formating is done in the pre-commit hook. This way nobody forgets it and diffs are way more readable
- mkdocs for simple markdown based documentation.
- mkdocstrings generates API-docs into mkdocs
- plantuml-markdown generates UML diagrams declaratively
Invoke is an established task runner and allows to define custom logic in Python and does not depend on platform dependent shells or tools. If tis is not important other task runners
The included simple script leverages existing invoke
tasks in a DRY manner. If a more complex setup is needed pre-commit could be an alternative.
Enable the pre-commit hook via inv install-hooks
(after the first poetry install && poetry shell
).