A simple template for Python projects, with CI/CD configured through GitHub Actions. Compatible with any virtual environment manager (e.g. venv
, pyenv
, poetry
, conda
).
-
Create a new repository, using this one as a template.
-
Run the
templatize
script:./templatize
This updates placeholders like
{{REPO_NAME}}
, so everything is configured with your username, repo name, email, etc. -
Commit and push the changes.
git add . git commit -m "Templatize" git push
-
(Probably) delete this section of the README.
pip install "{{REPO_NAME}} @ git+ssh://git@github.com/{{REPO_OWNER}}/{{REPO_NAME}}.git"
# Install all dev dependencies (tests etc.)
pip install "{{REPO_NAME}}[test] @ git+ssh://git@github.com/{{REPO_OWNER}}/{{REPO_NAME}}.git"
# Setup pre-commit hooks
pre-commit install
Tool | Description | Runs on |
---|---|---|
black | Code formatter | - git commit (through pre-commit ) - git push - pull requests |
ruff | Code linter | - git commit (through pre-commit ) - git push - pull requests |
pytest | Unit testing framework | - git push - pull requests |
mypy | Static type checker | - git push - pull requests |
pre-commit | Pre-commit hooks | - git commit
|
twine |
PyPI package uploader | - New release (git tag ) |
$\dagger$ Requires enabling thepublish.yaml
workflow. To activate, move the file from.github/disabled-workflows/publish.yaml.disabled
to.github/workflows/publish.yaml
, and set a valid PyPI token asPYPI_API_TOKEN
in the repo secrets.Then tag a new release of this repo, and GHA will automatically build and publish a Python wheel (
.whl
) to PyPI.