Skip to content

SpikingNeurons/python-polylith

 
 

Repository files navigation

✨ Python tools for the Polylith Architecture ✨

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

DavidVujic

What's Polylith? 😕

From the official docs:

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

Polylith is an architecture (with tooling support) originally built for Clojure. The code in this repo brings Polylith to Python!

An Architecture well suited for Monorepos

Polylith is using a components-first architecture. Similar to LEGO, components are building blocks. A component can be shared across apps, tools, libraries, serverless functions and services.

Polylith for Python? 🐍

This repo contains a Poetry plugin, that you can install from PyPI. The plugin will add Polylith specific tooling support to Poetry. Have a look in the Poetry Polylith Plugin project folder with details about the Poetry plugin.

✨ Examples ✨

Have a look at the Python Polylith Examples repository. It is a repository with an example Python setup 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.

Videos

poly-info-example

Differences between the Clojure & Python implementations

In the official docs for the Clojure implementation, there is a interface.clj file that is used to separate an API from the implementation of a component.

The Python implementation uses the __init__.py to accomplish that. In the Python implementation, the pyproject.toml is used to define bases and components. In particular, the packages property is used for that.

This is an example of the top level pyproject.toml used when developing. This is where you add all bricks (components and bases).

 packages = [
    {include = "development"},
    {include = "my_namespace/my_component", from = "components"},
    {include = "my_namespace/my_example_aws_lambda", from = "bases"},
]

(using the loose theme, see the Poetry Polylith Plugin docs)

When creating a project, the project specific pyproject.toml will include all the used components and bases. Note that the packages are referenced relative to the project.

This is where you add the bricks used by the actual project.

 packages = [
    {include = "my_namespace/my_component", from = "../../components"},
    {include = "my_namespace/my_example_aws_lambda", from = "../../bases"},
]

About

Tooling support for the Polylith Architecture in Python.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%