Cookiecutter for fast starting with polylith

ybenitezf

Yoel Benítez Fonseca

Posted on November 29, 2024

Cookiecutter for fast starting with polylith

Presenting to you a Python cookiecutter for fast starting with polylith in Python. If you do not know what polylith is read the documentation , for the impatient reader:

Polylith is a software architecture that aims to build simple, maintainable, testable, and scalable backend systems. It does this by applying functional thinking at the system scale, treating code as building blocks that can be combined into features.

And python-polylith is the tool that allow us to implement this in Python.

I won't go into details about the advantages of this approach. In this article I introduce you to poetry-poly-cc, a highly opinionated cookiecutter for starting a project with python-polylith.

You can start by installing cookiecutter and generating a project with:

cookiecutter https://github.com/ybenitezf/poetry-poly-cc.git
Enter fullscreen mode Exit fullscreen mode

Answer the questions and you are good. You should endup with something like:

.
├── LICENSE
├── README.md
├── bases
├── build-packages.sh
├── components
├── development
│   └── __init__.py
├── poetry.toml
├── projects
├── pyproject.toml
├── update-locks.sh
└── workspace.toml
Enter fullscreen mode Exit fullscreen mode

The firsts steps are included in the README.md:

Run

git init
poetry install
# install pre-commit hook
poetry run pre-commit install
# install pre-commit dependencies
poetry run pre-commit run -a
Enter fullscreen mode Exit fullscreen mode

What is included

  1. Poetry is configured to create the virtualenv in the project folder (see poetry.toml)
  2. pytest is added as a test dependency, also includes some goodies for pytest: pytest-mock, pytest-cov and pytest-asyncio
  3. pre-commit & ruff as dev dependencies.
  4. mypy for static typing check, integrated with pre-commit
  5. The support scripts build-packages.sh and update-locks.sh
  6. Recommended vscode extensions
💖 💪 🙅 🚩
ybenitezf
Yoel Benítez Fonseca

Posted on November 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related