|
1 | | -# poetry-polylith-plugin |
| 1 | +# Poetry Polylith Plugin |
2 | 2 |
|
3 | | -This is a Python `Poetry` plugin, adding CLI support for the Polylith architecture. |
| 3 | +This is a Python `Poetry` plugin, adding CLI support for the Polylith Architecture. |
4 | 4 |
|
5 | 5 |
|
| 6 | +## What's Polylith? |
| 7 | +From the [official docs](https://polylith.gitbook.io/polylith/): |
| 8 | + |
| 9 | +>... Polylith is a software architecture that applies functional thinking at the system scale. It helps us build simple, maintainable, testable, and scalable backend systems. ... |
| 10 | +
|
| 11 | +Polylith is an architecture (with tooling support) originally built for Clojure. |
| 12 | +With this Poetry plugin, Polylith is available in Python too! |
| 13 | + |
| 14 | +### An Architecture well suited for Monorepos |
| 15 | +Polylith is using a components-first architecture. Similar to LEGO, components are building blocks. |
| 16 | +A component can be shared across apps, tools, libraries, serverless functions and services. |
| 17 | + |
| 18 | + |
| 19 | +### Differences between the Clojure & Python implementations |
| 20 | +In the [official docs](https://polylith.gitbook.io/polylith/) for the Clojure implementation, |
| 21 | +there is a `interface.clj` file that is used to separate an API from the implementation of a component. |
| 22 | + |
| 23 | +The Python implementation uses the `__init__.py` to accomplish that. In the Python implementation, the `pyproject.toml` is used to define bases and components. |
| 24 | +In particular, the `packages` property is used for that. |
| 25 | + |
| 26 | +This is an example of the _top level_ `pyproject.toml` used when _developing_. This is where you add all bricks (components and bases). |
| 27 | + |
| 28 | +``` shell |
| 29 | + packages = [ |
| 30 | + {include = "development"}, |
| 31 | + {include = "my_namespace/my_component", from = "components"}, |
| 32 | + {include = "my_namespace/my_example_aws_lambda", from = "bases"}, |
| 33 | +] |
| 34 | +``` |
| 35 | +(using the `loose` theme, see more about that below) |
| 36 | + |
| 37 | +When creating a project, the _project specific_ `pyproject.toml` will include all the used components and bases. |
| 38 | +Note that the packages are referenced relative to the project. This is made possible by the Multiproject Poetry plugin. |
| 39 | + |
| 40 | +This is where you add the bricks used by the actual project. |
| 41 | + |
| 42 | +``` shell |
| 43 | + packages = [ |
| 44 | + {include = "my_namespace/my_component", from = "../../components"}, |
| 45 | + {include = "my_namespace/my_example_aws_lambda", from = "../../bases"}, |
| 46 | +] |
| 47 | +``` |
| 48 | + |
6 | 49 | ## Usage |
7 | 50 |
|
8 | 51 | ### Install Poetry & plugins |
|
0 commit comments