copier-rye
is a Copier template ideated to speed up the development process of Python applications. No more configuration hassle and boilerplate!
copier-rye
offers a production-ready development environment, with many useful features like formatting, linting, pre-commit hooks, and documentation already set up. Here's an overview of the features:
rye
is a comprehensive project and package management solution for Python.just
is a modern rewrite ofmake
in Rust 🦀pre-commit
validates your commits.ruff
provides static code analysis and a code and import formatting usingblack
andisort
styles.mypy
validates your type hints.pytest
runs your test suite.mkdocs
builds your documentation, whilemkdocs-material
provides an elegant theme.mike
takes care of versioning your docs.commitizen
ensures you follow Conventional commit style and generates your release changelogs according to SemVer
Note
Developer guidelines
- The template adopts to the
src
layout.mypy
is configured with a strict ruleset. The recommended approach to loosen those constraints is by temporary per-module ignores.ruff
is used to format the code usingblack
style, while imports are sorted withisort
style.- Releases follow Semantic Versioning.
- Commit follow the Conventional Commit specification.
Note
just
a command runner
just
recipes will save you a ton of time! Install just. To see the available recipes, run the following:just
curl -sSf https://rye-up.com/get | bash # For Linux/ Mac Users
# for example, on macOS
brew install just
For blazingly fast dependency install you can set rye
to use uv
under the hood when retrieving dependencies:
First of all, install uv
.
pipx install uv
Warning
🔎 Why
pipx
?pip install --user
is not recommended, as it does not ensure dependency isolation. For this purpose, the Python Packaging Authority (PyPA) advises to usepipx
.pipx
installs and runs python CLIs in isolated environments. To install it, follow the instructions here.
Then, configure rye
to use uv:
rye config --set-bool behavior.use-uv=true
If you want to create a new package, or any coding project, you just have to run two short commands.
- Initialise the template:
copier copy --trust gh:montanarograziano/copier-rye my-project
- Initialize GitHub repository locally (necessary to install pre-commit hooks) and install all default dependencies, running the following
just
recipe:
just init
For this command to execute successfully, you need to have rye
and the Git installed.
If you do not want to configure CI/CD on GitHub, you can simply run the following:
just install
Conventional commits are enforced with commitizen
, which is configured as a pre-commit
hook at pre-push time. In other words, if you attempt to push to a remote repo and your commit messages do not follow the conventional commits, the push will be rejected. However, commitizen
also offers a git command to commit with the conventional commit specification with a terminal UI. With just
, you can simply run the following:
just commit
Or even the shorter just c
. A prompt will guide you through the commit.
{
"project_name": "",
"project_description": "",
"author_fullname": "",
"author_email": "",
"author_username": "",
"repository_provider": "",
"repository_namespace": "",
"repository_name": "",
"copyright_holder": "",
"copyright_holder_email": "",
"copyright_date": "",
"copyright_license": "",
"ensure_python_version": "3.10",
"python_package_distribution_name": "",
"python_package_import_name": ""
}
project_name
: the name of the project indicated inpyproject.toml
.project_description
: the description of the project indicated inpyproject.toml
.author_fullname
: the author full name.author_email
: the author email address.repository_provider
: the repository provider (e.g., GitHub, GitLab, BitBucket). Only GitHub is supported for now.repository_namespace
: the repository namespace.package_name
: the package name.copyright_license
: the selected license.ensure_python_version
: the minimal python version required for the project.python_package_distribution_name
: the Python package distribution name (forpip install NAME
).python_package_import_name
: the Python package import name (forimport NAME
in Python code)
PR and issues are always accepted, especially since this project is far from being mature.
-
Install
rye
andjust
. -
Clone the repository:
# using github cli
gh repo clone montanarograziano/copier-rye
# using git (SSH recommended)
git clone [email protected]:montanarograziano/copier-rye
- Install the dependencies:
just install
Run the following:
just pre-release
The following operations will be performed:
- Format with
black
andisort
. - Lint with
ruff
. - Run type checks with
mypy
. - Audit dependencies with
pip-audit
. - Check commit messages are consistent with Conventional Commits using
commitizen
. - Check whether a version bump is possible.
- Run all tests.
This template is heavly inspired by @baggiponte Chef (based on Cookiecutter) and @pawamoy copier-uv (based on Copier). They use respectively pdm
and uv
as packaging solution. Both are very well done and works great, and so...
As of today, it seems that there are no Copier templates that uses rye
, given the novelty of the project.
Furthermore, sometimes a feature is not implemented in any available template or you need a custom one.
Personally, I believe that leveraging templating to abstract on stuff like dependency manager, is a possible solution: give the user many choices and let him decide which one suits him best.
Feel free to contact to discuss more about this topic!