So, you know how every time we start a new Python project, we end up copy-pasting config files from the last project, tweaking CI/CD workflows, and basically reinventing the wheel? Yeah, we've all been there. Well, I've got some good news, those days are behind us!
Let me introduce you to our new Trobz Python Template. Think of it as your project starter kit. It's designed to get you coding faster and keep our codebase consistent across all projects. Plus, it uses all the modern tools we're already familiar with from our OCA and Odoo work.
What's inside?
Our template is built on Copier, you might come across it when working with OCA repos. It’s a smart scaffolding tool, which will ask you a few questions and Voila! - you’ve got a fully configured Python project ready to roll.
Modern Tools - The Good Stuff We Already Know
The template include tools for Python development:
uv: Lightning-fast package management
ruff: Our code formatter and linter. You've probably seen it in OCA repos already. It's like having a super picky but helpful code reviewer who actually cares about consistency.
pre-commit: Automatic code quality checks before every commit
pytest: For all your testing needs.
ty: This stuff is new and really helpful in finding subtle bugs in your Python code.
CI/CD ready
When you enable GitHub Actions (Recommend), you get:Automated testing and linting
Automated releases: Push a conventional commit, and it'll bump versions and publish to Pypi (if configured)
Changelog generation: Automatically updates CHANGELOG.md
Just push your code and let the robots do the boring stuff!
Semantic Versioning Workflow
The template includes a fully automated semantic versioning workflow using python-semantic-release. Every time you push to the main branch (or PR is merged), this is workflow running automatically:Analyzes your commits
Determines the version bump depending on commit title
feat -> Minor version bump (0.1.0 → 0.2.0)
fix: -> Patch version bump (0.1.0 → 0.1.1)
feat! or a commit that has a footer BREAKING CHANGE: -> Major version bump (0.1.0 → 1.0.0)
Updates version in pyproject.toml - You don’t need to do it yourself!
Generates/updates CHANGELOG.md
Updates uv.lock - keeps your lock file in sync
Create distribution files with uv build
Create a Git tag
Pushes changes back to your repo
Create a Github Release with auto-generated release notes
Commit Types and Version Bumps
We follow Conventional Commits, which means your commits should look like:feat: add user authentication
fix: resolve login timeout issue
docs: update README
Why? Because our CI/CD automatically generates changelogs and version bumps.
All of this happens automatically. You just write good commit messages!
Note that, these commit DON'T trigger releases:
chore: Maintenance tasks
ci: CI/CD changes
style: Code formatting
test: Adding tests
docs: Documentation updates
Tip: intentionally skip Github actions by prefixing your commit [skip ci]
Publishing to Pypi
If you also enable publish_to_pypi, the workflow will additionally:Upload your package to PyPI after each release
Make it installable via pip install your-package
This requires setting up a trusted publisher for your project, read it here.
Consistent Project Structure
Every project follows the same layout:Pre-configured pyproject.toml with sensible defaults
Makefile with common commands (make install, make check, make test, etc.)
Comprehensive .gitignore
AGPL-3.0 license by default
Getting Started?
1. Create a New Project
$ copier copy "https://github.com/trobz/trobz-python-template.git" /path/to/your/new/project
2. Install and Set Up
$ cd /path/to/your/new/project
# Install everything (creates venv, installs deps, sets up pre-commit)
$ make install
3. Start Coding!
4. Release to the world
Conclusion
Next time you're starting a Python project, give Trobz Python Template a spin. It's designed to get out of your way and let you focus on building cool stuff.