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
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
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
What is included
- Poetry is configured to create the virtualenv in the project folder (see
poetry.toml
) -
pytest is added as a test dependency, also includes some goodies for pytest:
pytest-mock
,pytest-cov
andpytest-asyncio
-
pre-commit
&ruff
as dev dependencies. -
mypy
for static typing check, integrated withpre-commit
- The support scripts
build-packages.sh
andupdate-locks.sh
- Recommended vscode extensions
Top comments (0)