diff --git a/README.md b/README.md index f94dd52b..b396e56e 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Have a look at the [Python-specific documentation](https://davidvujic.github.io/ You will find installation, setup, usage guides and more. ## Polylith for Python? :snake: -This repo contains a Poetry plugin, a CLI that enables support for Hatch and PDM. +This repo contains a Poetry plugin, a CLI that enables support for __Hatch__, __PDM__ and __Rye__. There's a Hatch Build Hook plugin and a PDM build hooks to fully support these tools. * [a Poetry Plugin](https://pypi.org/project/poetry-polylith-plugin) @@ -38,7 +38,9 @@ There's a Hatch Build Hook plugin and a PDM build hooks to fully support these t The Poetry plugin adds Polylith specific tooling support to Poetry. The CLI adds tooling support for Polylith, and enables different kinds of Package & Dependency Management tools (such as Hatch and PDM). -The Hatch Build Hook adds support for building Libraries from Polylith with Hatch. + +The Hatch Build Hook adds support for building Libraries from Polylith with Hatch (and Rye, using hatchling as a build backend by default). + The PDM Build Hook for projects add support for building apps, services and libraries from Polylith using 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). @@ -56,6 +58,7 @@ There's example Polylith repositories for: - [Poetry](https://github.com/DavidVujic/python-polylith-example) - [Hatch](https://github.com/DavidVujic/python-polylith-example-hatch) - [PDM](https://github.com/DavidVujic/python-polylith-example-pdm) +- [Rye](https://github.com/DavidVujic/python-polylith-example-rye) The repositories are example __Python__ setups of the Polylith Architecture. You will find examples of sharing code between different kind of projects, diff --git a/projects/polylith_cli/README.md b/projects/polylith_cli/README.md index 65b04dc1..8c75b62f 100644 --- a/projects/polylith_cli/README.md +++ b/projects/polylith_cli/README.md @@ -120,5 +120,65 @@ pdm run poly create base --name my_example_endpoint pdm run poly create project --name my_example_project ``` +## Setup for Rye users +``` shell +rye init my_repo # name your repo + +cd my_repo + +rye add polylith-cli --dev + +rye sync # create a virtual environment and lock files +``` + +Create a workspace, with a basic Polylith folder structure. + +``` shell +rye run poly create workspace --name my_namespace --theme loose +``` + +### Edit the configuration +The default build backend for Rye is Hatch. Add the `hatch-polylith-bricks` build hook plugin to the `pyproject.toml` file. + +``` toml +[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: +``` toml +[tool.hatch.build] +dev-mode-dirs = ["components", "bases", "development", "."] +``` + +Remove the `[project.scripts]` and `[tool.hatch.build.targets.wheel]` sections. + +Run the `sync` command to update the virtual environment: + +``` shell +rye sync +``` + +Finally, remove the `src` boilerplate code that was added by Rye in the first step: +``` shell +rm -r src +``` + +### Ready for coding! + +Add components, bases and projects: + +``` shell +rye run poly create component --name my_component + +rye run poly create base --name my_example_endpoint + +rye run poly create project --name my_example_project +``` + For details, have a look at the [documentation](https://davidvujic.github.io/python-polylith-docs/). There, you will find guides for setup, migration, packaging, available commands, code examples and more. diff --git a/projects/polylith_cli/pyproject.toml b/projects/polylith_cli/pyproject.toml index 11f67156..e4c96600 100644 --- a/projects/polylith_cli/pyproject.toml +++ b/projects/polylith_cli/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "polylith-cli" -version = "1.1.1" +version = "1.1.2" description = "Python tooling support for the Polylith Architecture" authors = ['David Vujic'] homepage = "https://davidvujic.github.io/python-polylith-docs/"