Full-featured, very opinionated template for Python projects
- Packaging with
poetry
- Documentation with
sphinx
and Read the Docs - Testing with either
compileall
orpytest
- CI/CD with GitHub Actions, Docker and Portainer Business
This template is intended to be used with pipx
and cookiecutter
.
To initialize a new project with this template, follow the instructions in the next sections.
-
Install
pipx
following the instructions for your platform. -
Install
cookiecutter
usingpipx
:$ pipx install cookiecutter
-
Use
cookiecutter
to initialize a new project, then answer the questions to fill in the template:$ cookiecutter gh:Steffo99/template-poetry project_name [example-project]: project_identifier [example_project]: Select project_type: 1 - application 2 - library Choose from 1, 2 [1]: project_description [A demo of Steffo99/template-poetry]: Select project_docs: 1 - sphinx 2 - none Choose from 1, 2 [1]: Select project_tests: 1 - compileall 2 - none 3 - pytest Choose from 1, 2, 3 [1]: project_license [AGPL-3.0-or-later]: project_author_name [Firstname Lastname]: project_author_email [[email protected]]: project_author_full [Firstname Lastname <[email protected]>]: docs_theme_color [#123abc]: github_owner [ghost]:
-
Access the created directory:
$ cd example-project
-
Initialize a Git repository in it:
$ git init $ git add . $ git commit --message "First commit"
-
Create a new repository on GitHub for it, either via the web interface or via
gh
, then add it as a remote on your local copy of the repository and force push to it:$ gh repo create --public --template Steffo99/template-poetry example-project $ git remote add origin [email protected]:ghost/example-project.git $ git push --force --set-upstream origin main
- Create an API token on PyPI and set it on GitHub as the
PYPI_TOKEN
repository secret.
- Create a stack on [Portainer], configure it to be updated via webhook, and set the webhook URL on GitHub as the
PORTAINER_HOOK_URL
repository secret.