Poetry workspace plugin for Python monorepos.

Overview

poetry-workspace-plugin

Poetry workspace plugin for Python monorepos. Inspired by Yarn Workspaces.

Adds a new subcommand group, poetry workspace, which is used to create, manage and inspect nested Python projects.

# 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:

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:

# 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:

[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:

pyenv shell 3.9.4  # Or other 3.9.x
pre-commit install  # Configure commit hooks
poetry install  # Install Python dependencies

Run tests:

poetry run inv verify

License

This project is distributed under the MIT license.

You might also like...
Tensorboard plugin 3d with python
Tensorboard plugin 3d with python

tensorboard-plugin-3d Overview In this example, we render a run selector dropdown component. When the user selects a run, it shows a preview of all sc

Python plugin/extra to load data files from an external source (such as AWS S3) to a local directory

Data Loader Plugin - Python Table of Content (ToC) Data Loader Plugin - Python Table of Content (ToC) Overview References Python module Python virtual

A Linux webcam plugin for BGMv2 as used in our demos.

The goal of this repository is to supplement the main Real-Time High Resolution Background Matting repo with a working demo of a videoconferencing plu

flake8 plugin which forbids match statements (PEP 634)

flake8-match flake8 plugin which forbids match statements (PEP 634)

A minimalist production ready plugin system

pluggy - A minimalist production ready plugin system This is the core framework used by the pytest, tox, and devpi projects. Please read the docs to l

A PDM plugin to publish to PyPI

PDM Publish A PDM plugin to publish to PyPI NOTE: Consider if you need this over using twine directly Installation If you installed pdm via pipx: pipx

Simple card retirement plugin for Anki

Anki Retirement Addon Allow users to suspend, tag, delete, or move cards that reach a specific retirement interval Supports Anki version 2.1.45 Licens

A maubot plugin to invite users to Matrix rooms according to LDAP groups

LDAP Inviter Bot This is a maubot plugin that invites users to Matrix rooms according to their membership in LDAP groups.

Plugin to generate BOM + CPL files for JLCPCB
Plugin to generate BOM + CPL files for JLCPCB

KiCAD JLCPCB tools Plugin to generate all files necessary for JLCPCB board fabrication and assembly Gerber files Excellon files BOM file CPL file Furt

Comments
  • [PROPOSAL] Specify `workspaces` in `pyproject.toml` via subsection, rather than inline table

    [PROPOSAL] Specify `workspaces` in `pyproject.toml` via subsection, rather than inline table

    First of all - dope plugin. Think it's a great project!

    Currently

    workspaces under tool.poetry-workspace-plugin are specified via a single inline table. With many workspaces, this can get unreadable because TOML doesn't allow linebreaks in inline table syntax.

    There's a discussion about allowing linebreaks in the syntax for inline tables, but not sure it's going to go anywhere.

    Suggest

    Allow workspaces option to be a subsection. The spec would be

    [tool.poetry-workspace-plugin.workspaces]
    workspace1 = "path-to-workspace1"
    workspace2 = "path-to-workspace2"
    

    If you think it's something of value, I can do a quick and easy PR.

    opened by ttzhou 1
  • Specify workspaces via table (dedicated section) instead of inline

    Specify workspaces via table (dedicated section) instead of inline

    Proposed resolution for: #2

    Didn't add a CHANGELOG message as there is no currently established format - let me know if you want me to start a new one.

    Check list

    Before asking for a review

    • [x] Target branch is main
    • [ ] [Unreleased] section in CHANGELOG.md is updated.
    • [x] I reviewed the "Files changed" tab and self-annotated anything unexpected.

    Before review (reviewer)

    • [ ] All of the above are checked and true. Review ALL items. If not, return the PR to the author.
    • [ ] Continuous Integration is passing. If not, return the PR to the author.

    After merge (reviewer)

    • [ ] Any issues that may now be closed are closed.
    opened by ttzhou 0
  • Add workspace build command

    Add workspace build command

    Any related Github Issues?: add link here

    What has changed? This should match CHANGELOG.md.

    This PR introduces a workspace build command, which builds workspaces and replaces the directory reference of each workspace dependency with its version in the distribution manifest during packaging similarly to the way Cargo, Yarn and npm workspaces do.

    Design choices:

    Doesn't change the default poetry behavior

    According to the poetry documentation, an application plugin shouldn't change the behavior of the default poetry commands. https://python-poetry.org/docs/master/plugins/. Thus, instead of augmenting poetry build, I introduced a new plugin command poetry workspace build.

    Executable from the root or from within a workspace

    The workspace build command can be executed in the root package, in which case traverses each workspace and runs the build (with the augmented logic) in their respective environments. It can also be executed from within the confines of an individual workspace. This way it only builds the workspace for which it is invoked. To be able to discover the root (which is necessary for wiring the deps), I introduced a parent field in tool.poetry-workspace-plugin. Alternative approaches:

    • if we don't want to invoke workspace build from within a workspace, the parent project discovery is not required
    • we could do a recursive directory traversal up to the fs root to find the parent project instead

    Configurable ranges

    By default, workspace build uses the exact version for each workspace dependency. However, following the design of workspaces in Yarn, we could allow for ranges. https://yarnpkg.com/features/workspaces I propose following notation:

    • <empty string>: exact version
    • ^ / ~: caret / tilde range on the exact version
    • *: any version (wildcard)
    • .*: minor wilcard (e.g 4.1.2 -> 4.*) (TBD)
    • ..*: patch wildcard (e.g 4.1.2 -> 4.1.*) (TBD)

    The code quality has to be improved and there are no test yet, but can be tried out in this example project: https://github.com/dszakallas/poetry-workspace-plugin-build-example

    Check list

    Before asking for a review

    • [ ] Target branch is master
    • [ ] Implement tests
    • [ ] [Unreleased] section in CHANGELOG.md is updated.
    • [ ] I reviewed the "Files changed" tab and self-annotated anything unexpected.

    Before review (reviewer)

    • [ ] All of the above are checked and true. Review ALL items. If not, return the PR to the author.
    • [ ] Continuous Integration is passing. If not, return the PR to the author.

    After merge (reviewer)

    • [ ] Any issues that may now be closed are closed.
    opened by dszakallas 0
  • How to install

    How to install

    I'm really excited to see this plugin evolve. IMO it's a missing piece in the python community - easily manage a monorepo.

    Can you add some additional information how to install the plugin? You write that you need to clone this project but I assume you need to add the plugin in pyproject.toml as well. I've copied poetry_workspace_plugin folder to the root in my monorepo and added the following to pyproject.toml.

    [tool.poetry.plugins."poetry.application.plugin"]
    poetry-workspace-plugin = "poetry_workspace_plugin:WorkspacePlugin"
    

    Unfortunately I get The command "workspace" is not defined.. I'm using poetry version 1.1.12.

    opened by NixBiks 4
Owner
Jack Smith
Jack Smith
A plugin for poetry that allows you to execute scripts defined in your pyproject.toml, just like you can in npm or pipenv

poetry-exec-plugin A plugin for poetry that allows you to execute scripts defined in your pyproject.toml, just like you can in npm or pipenv Installat

null 38 Jan 6, 2023
🛠️ Plugin to integrate Chuy with Poetry

Archived This is bundled with Chuy since v1.3.0. Poetry Chuy Plugin This plugin integrates Chuy with Poetry. Note: This only works in Poetry 1.2.0 or

Eliaz Bobadilla 4 Sep 24, 2021
This is a Poetry plugin that will make it possible to build projects using custom TOML files

Poetry Multiproject Plugin This is a Poetry plugin that will make it possible to build projects using custom TOML files. This is especially useful whe

David Vujic 69 Dec 25, 2022
Demo Python project using Conda and Poetry

Conda Poetry This is a demonstration of how Conda and Poetry can be used in a Python project for dev dependency management and production deployment.

Ryan Allen 2 Apr 26, 2022
Bazel rules to install Python dependencies with Poetry

rules_python_poetry Bazel rules to install Python dependencies from a Poetry project. Works with native Python rules for Bazel. Getting started Add th

Martin Liu 7 Dec 15, 2021
Canim1 - Simple python tool to search for packages without m1 wheels in poetry lockfiles

canim1 Usage Clone the repo. Run poetry install. Then you can use the tool: ❯ po

Korijn van Golen 1 Jan 25, 2022
poetry2nix turns Poetry projects into Nix derivations without the need to actually write Nix expressions

poetry2nix poetry2nix turns Poetry projects into Nix derivations without the need to actually write Nix expressions. It does so by parsing pyproject.t

Nix community projects 405 Dec 29, 2022
A simple but flexible plugin system for Python.

PluginBase PluginBase is a module for Python that enables the development of flexible plugin systems in Python. Step 1: from pluginbase import PluginB

Armin Ronacher 1k Dec 16, 2022
A simple but flexible plugin system for Python.

PluginBase PluginBase is a module for Python that enables the development of flexible plugin systems in Python. Step 1: from pluginbase import PluginB

Armin Ronacher 935 Feb 20, 2021
tox-gh is a tox plugin which helps running tox on GitHub Actions with multiple different Python versions on multiple workers in parallel

tox-gh is a tox plugin which helps running tox on GitHub Actions with multiple different Python versions on multiple workers in parallel. This project is inspired by tox-travis.

tox development team 19 Dec 26, 2022