Skip to content

Commit

Permalink
docs(rye): add quick start and basic info (#165)
Browse files Browse the repository at this point in the history
* docs: add info and links about Rye

* docs(cli): add quick start for Rye

* bump CLI version to 1.1.2
  • Loading branch information
DavidVujic authored Jan 31, 2024
1 parent d835402 commit 9ede9ed
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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).

Expand All @@ -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,
Expand Down
60 changes: 60 additions & 0 deletions projects/polylith_cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion projects/polylith_cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down

0 comments on commit 9ede9ed

Please sign in to comment.