Package: polylith-cli
Python tooling for PolylithA command line interface that adds tooling support for the Polylith Architecture in Python.DocumentationHave a look at thedocumentation.
You will find installation, setup, usage guides and more.Quick startPoetryuser? For Poetry, the recommended setup is to install thepoetry-polylith-plugin.
Read more about Poetry in thedocumentation.Setup for Hatch usersCreate a directory for your code, initialize it withgitand setup the basics withhatch:gitinit

hatchnew--initAdd the Polylith CLI as a dev dependency inpyproject.toml:[tool.hatch.envs.default]dependencies=["polylith-cli"]Add configuration for a local virtual environment in thepyproject.toml:[tool.hatch.envs.default]type="virtual"path=".venv"python="3.12"# your preferred version hereMakeHatchaware of the Polylith structure, by adding this to thepyproject.toml:[tool.hatch.build]dev-mode-dirs=["components","bases","development","."]Next: create a Polylith workspace, with a basic Polylith folder structure.
Thepolycommand is now available in the local virtual environment.
You can run commands in the context ofhatch runto make Polylith aware of the development environment.hatchrunpolycreateworkspace--namemy_namespace--themelooseReady for coding!Add components, bases and projects:hatchrunpolycreatecomponent--namemy_component

hatchrunpolycreatebase--namemy_example_endpoint

hatchrunpolycreateproject--namemy_example_projectFor details, have a look at thedocumentation.
There, you will find guides for setup, migration, packaging, available commands, code examples and more.Setup for PDM usersCreate a directory for your code, initialize it withgitand setup the basics withPDM.gitinit

pdminit-n--backendpdm-backendminimalAdd a workspace hookMakePDMaware of the Polylith structure, by adding thepdm-polylith-workspacehook to the newly createdpyproject.toml.The build hook will add an additionalpthfile to the virtual environment,
with paths to the Polylith source code folders (bases, components).[build-system]requires=["pdm-backend","pdm-polylith-workspace"]build-backend="pdm.backend"Add the polylith-cliAdd the Polylith CLI as a dev dependency and setup the virtual environment paths.touchREADME.md

pdmadd-dpolylith-cli

pdminstallNext: create a Polylith workspace, with a basic Polylith folder structure.
Thepolycommand is now available in the local virtual environment.
You can run commands in the context ofpdm runto make Polylith aware of the development environment.pdmrunpolycreateworkspace--namemy_namespace--themelooseReady for coding!Add components, bases and projects:pdmrunpolycreatecomponent--namemy_component

pdmrunpolycreatebase--namemy_example_endpoint

pdmrunpolycreateproject--namemy_example_projectSetup for Rye usersryeinitmy_repo# name your repocdmy_repo

ryeaddpolylith-cli--dev

ryesync# create a virtual environment and lock filesCreate a workspace, with a basic Polylith folder structure.ryerunpolycreateworkspace--namemy_namespace--themelooseEdit the configurationThe default build backend for Rye is Hatch. Add thehatch-polylith-bricksbuild hook plugin to thepyproject.tomlfile.[build-system]requires=["hatchling","hatch-polylith-bricks"]build-backend="hatchling.build"[tool.hatch.build.hooks.polylith-bricks]# this section is needed to enable the hook in the build process, even if empty.Make Rye (and Hatch) aware of the way Polylith organizes source code:[tool.hatch.build]dev-mode-dirs=["components","bases","development","."]Remove the[project.scripts]and[tool.hatch.build.targets.wheel]sections.Run thesynccommand to update the virtual environment:ryesyncFinally, remove thesrcboilerplate code that was added by Rye in the first step:rm-rsrcReady for coding!Add components, bases and projects:ryerunpolycreatecomponent--namemy_component

ryerunpolycreatebase--namemy_example_endpoint

ryerunpolycreateproject--namemy_example_projectFor details, have a look at thedocumentation.
There, you will find guides for setup, migration, packaging, available commands, code examples and more.