A personal Python project template I use to spin up new libraries and CLIs without setting up packaging, linting, and release pipelines from scratch every time.
This repo is public so feel free to fork or borrow from it, though it is tailored to my own setup by default. I have 0jar on Codeberg as primary, GitHub as mirror, PyPI with PEP 740 provenance, uv, ruff, mypy --strict and 2-space indentation. If you use it for your own projects, pass --owner, --author, and --email to init_project.py and update SECURITY.md with your own contact details.
- src/ package layout built with hatchling and uv, with PEP 561 py.typed marker and a minimal CLI entry point
- ruff formatting and linting (including Bandit S rules),
mypy --strict, .editorconfig and pytest - A uv.lock pin check in tests/test_pins.py that tests across Python 3.11+
- Matrix CI workflow in .github/workflows/ci.yml (Python 3.11, 3.12, 3.13 and 3.14)
- Release workflow in .github/workflows/publish.yml that verifies the release tag against both HEAD and pyproject.toml, tests and builds once, then publishes to PyPI (OIDC Trusted Publishing + PEP 740 attestations), Codeberg's PyPI registry, Codeberg Releases, and GitHub Releases with SHA256SUMS.txt
- Starter LICENSE (MIT), SECURITY.md and init_project.py bootstrap script
git clone https://codeberg.org/0jar/python-template my-new-tool
cd my-new-tool
rm -rf .git && git init
# For my repos
python3 init_project.py my-new-tool -d "One-line description of my-new-tool."
# Override identity if you're using this template
python3 init_project.py my-new-tool -d "One-line description." --owner yourhandle --author "Your Name" --email you@example.cominit_project.py renames src/my_package/, replaces all placeholders across pyproject.toml, workflows, tests, and SECURITY.md, writes a clean starter README.md for your new project, refreshes uv.lock and .venv and deletes itself.
- On PyPI (https://pypi.org/manage/account/publishing/), add a pending Trusted Publisher for your package name, GitHub owner/repo, workflow
publish.ymland environmentpypi. - In your GitHub repository settings under Environments, create
pypiandcodeberg, allowv*tags under Deployment branches and tags on both, then save a Codeberg token (write:package and write:repository) as CODEBERG_TOKEN inside thecodebergenvironment. - On Codeberg, configure the GitHub push mirror with a GitHub token that includes workflow push permission (set "workflows" to Read and write).
Template files are licensed under the MIT License.