In recent years I have written a lot of python packages, but that also means that your backlog for maintenance is getting bigger and bigger. And in addition, you don’t always want to copy, paste and adjust all files from your previous project for each new project. I wanted to get rid of that and set up a template that works with Copier.
Copier template
I’ve created a one-command template for python projects using my preferred format. Upon execution, you will be prompted with a questionnaire asking for information such as the desired package name, your Github handle, and your preferences.
Once you have completed the questionnaire, the basis of your package will be ready and you can start with writing your Python code. This template aims to make the process of setting up a new Python project more efficient by automating the initial setup and allowing you to quickly get started on the actual coding.
Feature Summary
- GitHub Actions for continuous integration and publishing to PyPI
- Poetry for dependency management and packaging
- Thrusted publishers for PyPI releases
- Dev Containers for easy development in VS Code
- Renovate Bot for dependency updates
- Black for code formatting
- mypy for static type checking
- pytest for testing with code coverage
- Ruff for linting
To address the issue of Renovate being unable to update the pyproject.toml
file in the template folder due to it being a Jinja file, I created a special GitHub action workflow. This workflow automatically updates the dependencies within the Jinja file during Renovate’s weekly lock maintenance. The updated dependency versions are sourced from a separate Gist, which I can easily manually update when needed.
Default config files
Setting up a central config repository is an effective way for developers to manage multiple repositories and maintain consistency across projects. This config repository stores commonly used files such as Renovate configuration and GitHub actions workflows.
By including a sync.yml file in the central repository, you can specify which files should be copied over to other repositories automatically. When a new release is published, a pull request is created for each supported repository. This automated process saves time and ensures consistency across all related repositories.
So merge the pull request and you’re ready 😉