Skip to main content

Poetry Monoranger Plugin

PyPI - Version GitHub License Tests

Monoranger is a plugin for Poetry that helps you manage your monorepo.

Main Features:

  • Shared poetry.lock file across multiple projects in a monorepo
  • Shared virtual environment across multiple projects in a monorepo
  • Replace path dependencies during poetry build and poetry export with pinned versions
  • Compatible with both Poetry v1 and v2

Installation

poetry self add poetry-monoranger-plugin

Usage

Expected project structure

The plugin is generally flexible when it comes to the structure of the repository. However, it is expected that each project will have its own pyproject.toml file and that the root of the repository will also have a central pyproject.toml file including all projects as a path dependency.

monorepo/
├── library-one/
│   ├── pyproject.toml
│   └── library_one/
├── library-two/
│   ├── pyproject.toml
│   └── library_two/
├── poetry.lock
└── pyproject.toml

The root pyproject.toml file should include all projects as a path dependency:

# ...
[tool.poetry.dependencies]
python = "^3.9"
library-one = { path = "library-one", develop = true }
library-two = { path = "library-two", develop = true }
# ...

Each project's pyproject.toml file should include the dependencies it needs (including path dependencies to other projects) as well as enabling the plugin:

# ...
[tool.poetry.dependencies]
python = "^3.9"
numpy = "^1.21.0"
library-two = { path = "../library-two", develop = true }

[tool.poetry-monoranger-plugin]
enabled = true
monorepo-root = "../"
version-pinning-rule = '=='  # Choose between "==", "~", "^", ">=,<"
# ...

The plugin by default is disabled in order to avoid having undesired consequences on other projects (as plugins are installed globally). To enable it, set enabled = true in each project's pyproject.toml file.

Commands

The plugin modifies the following commands:

  • poetry lock:

Ensures that the shared lock file (located at the root) is up-to-date irrespective of the directory from which the command is run. This is convenient since it avoids accidentally creating a per-project lock file when running from within a project directory. It also eliminated the need to switch to the root directory to update the lock file.

  • poetry install:

Installs dependencies for all projects in the monorepo, ensuring that the shared virtual environment is used. As before, this command can be run from any directory within the monorepo without needing to switch to the root directory.

  • poetry sync (v2 only):

Installs dependencies for all projects in the monorepo, ensuring that the shared virtual environment is used, removing any dependencies that do not exist in the lockfile. As before, this command can be run from any directory within the monorepo without needing to switch to the root directory.

  • poetry update:

Updates the provided dependency (or all dependencies of current project if none provided). This will update the shared lock file as well as installing the updated dependencies in the shared virtual environment.

  • poetry add:

Adds a new dependency to the pyproject.toml of the current project, updates the shared lock file, and installs the new dependency in the shared virtual environment. This is equivalent to manually modifying a project's pyproject.toml file, followed by running poetry lock and poetry install from the root directory.

  • poetry remove:

Removes a dependency from the specified project, updates the shared lockfile, and removes the dependency from the shared virtual environment if it is no longer required by any other project.

  • poetry build:

Builds the current project, replacing editable path dependencies with the current version of the package. This is useful when building a project that depends on another project in the monorepo, as it ensures that the built package can be installed (e.g. as a wheel file) without expecting the other project to be present in a specific location.

  • poetry export:

Export the requirements of the current project, replacing editable path dependencies with the current version of the packages. This is useful when exporting the requirements of a project that depends on another project in the monorepo, as it ensures that the exported requirements can be installed without expecting the other project to be present in a specific location.

Configuration

The plugin can be configured in the pyproject.toml file of each project. The following options are available:

  • enabled (bool): Whether the plugin is enabled for the current project. Default: false
  • monorepo-root (str): The path to the root of the monorepo. Default: ../
  • version-pinning-rule (str): The version pinning rule to apply when building the project. Default: ==

License

This project is licensed under the Apache 2.0 license - see the LICENSE file for details.

Metadata

Release files for poetry-monoranger-plugin 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for poetry-monoranger-plugin 0.4.1
File Size Uploaded Provenance Actions
poetry_monoranger_plugin-0.4.1.tar.gz 16.5 kB Without provenance Details for poetry_monoranger_plugin-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for poetry-monoranger-plugin 0.4.1
File Interpreter ABI Platform Actions
poetry_monoranger_plugin-0.4.1-py3-none-any.whl Python 3 none any Details for poetry_monoranger_plugin-0.4.1-py3-none-any.whl

Total release size: 37.1 kB

Release files / poetry_monoranger_plugin-0.4.1.tar.gz

Download URL poetry_monoranger_plugin-0.4.1.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b837a0bf81946b77d8f6e78979cc5d873e4cce9365e988ef9dc98893e3587152
BLAKE2b-256 checksum
How to use checksums
fe05168a5f30dd914954a26a1bb5cd667e34e0b6682737d9d8396ab21219a404
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.9.21 Linux/6.8.0-1021-azure

Release files / poetry_monoranger_plugin-0.4.1-py3-none-any.whl

Download URL poetry_monoranger_plugin-0.4.1-py3-none-any.whl
Size 20.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4887cd63773c6eba30f2b9dc6652a8b5194e186a34b3a1e0e55f28022452911
BLAKE2b-256 checksum
How to use checksums
b225cc167b1c693b620add7dbb225a8f44216a3bfa84534a7a68a334b4e33c70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.9.21 Linux/6.8.0-1021-azure

Security for poetry-monoranger-plugin 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page