Skip to content

DavidVujic/python-polylith

Repository files navigation

✨ Python tools for the Polylith Architecture ✨

A repo containing tooling support for the Polylith Architecture in Python.

The main use case is to support having one or more microservices (or apps) in a Monorepo, and share code between the services.

DavidVujic

CodeScene Code Health

Quality Gate Status

Download Stats

Download Stats

What's Polylith? 🤔

... Polylith is a software architecture that applies functional thinking at the system scale. It helps us build simple, maintainable, testable, and scalable backend systems. ... (from the Polylith Architecture docs)

Polylith is an architecture, with tooling support, that was originally built for Clojure. This repo brings Polylith to Python.

Polylith is using a components-first architecture. You can think of it as building blocks, very much like LEGO bricks. All code lives in a Monorepo, available for reuse. Python code - the bricks - is separated from the infrastructure and the actual building of artifacts.

Use cases

Microservices and apps 👍

The main use case is to support having one or more microservices (or apps) in a Monorepo, and share code between the services.

Libraries

Polylith for Python has support for building libraries to be published at PyPI, even if it isn't the main use case. More details about how to package libraries in the docs about Packaging & deploying.

Documentation 📚

Have a look at the Python-specific documentation. You will find installation, setup, usage guides, examples and more.

Python Monorepos with Polylith 🐍

You can use Polylith with Poetry, Hatch, PDM, Rye, uv and Pantsbuild. This repo contains a Poetry plugin, a standalone CLI and build hooks.

The Poetry plugin adds tooling support to Poetry. The CLI adds tooling support for several Package & Dependency Managers (such as Hatch, PDM, Rye and uv).

The Hatch Build Hook adds build-specific support (also for uv, Rye and Pantsbuild, using hatchling as the build backend). The PDM Build Hook for projects adds build-specific support for PDM. The PDM Build Hook for the workspace makes the virtual environment aware of the way Polylith organizes code (i.e. the bases and components folders).

✨ Examples and Production systems ✨

There's example Polylith repositories for:

The repositories are example Python setups of the Polylith Architecture. You will find examples of sharing code between different kind of projects, and developer tooling setup such as mypy and the venv.

There's more examples and production systems in the documentation.

Videos

Talks

Podcasts

Articles

Repo Visualization

A visualization of this repo (that itself is a Polylith workspace) using the poly info command.

poly-info