https://github.com/jacksmith15/poetry-workspace-plugin
Poetry workspace plugin for Python monorepos.
https://github.com/jacksmith15/poetry-workspace-plugin
Last synced: 10 months ago
JSON representation
Poetry workspace plugin for Python monorepos.
- Host: GitHub
- URL: https://github.com/jacksmith15/poetry-workspace-plugin
- Owner: jacksmith15
- License: mit
- Created: 2021-08-09T19:56:52.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-05-04T10:26:07.000Z (about 3 years ago)
- Last Synced: 2024-12-09T17:58:09.270Z (over 1 year ago)
- Language: Python
- Size: 67.4 KB
- Stars: 85
- Watchers: 8
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-machine-learning-engineer - Poetry workspace plugin - How to create and manage a Poetry-based monorepo (15 min) (Software Engineering / Workflow)
README
# poetry-workspace-plugin
> :warning: This depends on the plugin system added in Poetry [1.2](https://github.com/python-poetry/poetry/releases/tag/1.2.0a1), which does not yet have a stable release.
>
> If you want to use this in your project now, check out [**Workspace**](https://jacksmith15.github.io/workspace-cli/basic-usage/), a standalone and extensible version of this plugin with built-in support for both [Poetry](https://python-poetry.org/) and [Pipenv](https://pipenv.pypa.io/en/latest/).
[Poetry](https://python-poetry.org/) workspace plugin for Python monorepos. Inspired by [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/).
Adds a new subcommand group, `poetry workspace`, which is used to create, manage and inspect nested Python projects.
```shell
# Create a new python project at the specified path, tracked in the current project
poetry workspace new libs/my-library
# Add an existing python project to the current project's workspaces
poetry workspace add libs/my-existing-library
# List the current workspaces
poetry workspace list
# Run a command in every workspace:
poetry workspace run command
# Run a command in specified workspaces:
poetry workspace run --targets=my-library,my-existing-library -- command
# List dependees of a particular workspace (from among the list of workspaces).
poetry workspace dependees my-library
# Unlink a workspace from the current project
poetry remove workspace my-library
# Unlink and delete a workspace from the current project
poetry remove workspace my-library --delete
```
### Common patterns
#### Testing affected workspaces
After making a change to a workspace, you can run tests for all _affected_ workspaces like so:
```shell
poetry workspace run --targets=$(poetry workspace dependees --csv my-library) -- pytest tests/
```
### Planned commands
The following are currently possible e.g via `poetry workspace run poetry build`, but this would be more succint:
```shell
# Build or publish all workspaces:
poetry workspace build
poetry workspace publish
# Build specified workspaces:
poetry workspace --targets=my-library build
# Publish specified workspaces:
poetry workspace --targets=my-library publish
```
Metadata regarding workspaces is stored under `tool.poetry.workspaces`:
```toml
[tool.poetry.workspace]
workspaces = {
my-library = "libs/my-library"
}
```
## Installation
This project is not currently packaged and so must be installed manually.
Clone the project with the following command:
```
git clone https://github.com/jacksmith15/poetry-workspace-plugin.git
```
## Development
Install dependencies:
```shell
pyenv shell 3.9.4 # Or other 3.9.x
pre-commit install # Configure commit hooks
poetry install # Install Python dependencies
```
Run tests:
```shell
poetry run inv verify
```
# License
This project is distributed under the MIT license.