Home > Backend Development > Python Tutorial > Cookiecutter for fast starting with polylith

Cookiecutter for fast starting with polylith

DDD
Release: 2024-12-01 18:35:11
Original
848 people have browsed it

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
Copy after login

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
Copy after login

The firsts steps are included in the README.md:

  • Install poetry: https://python-poetry.org/docs/#installation
  • Add polylith tooling: https://davidvujic.github.io/python-polylith-docs/installation/

Run

git init
poetry install
# install pre-commit hook
poetry run pre-commit install
# install pre-commit dependencies
poetry run pre-commit run -a
Copy after login

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

The above is the detailed content of Cookiecutter for fast starting with polylith. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template