Skip to main content

Poetry Monorepo Dependency Plugin

PyPI PyPI - Python Version PyPI - Wheel PyPI - Downloads License Build (github)

Forked and inspired by the poetry-stickywheel-plugin, this Poetry plugin facilitates the usage of more complex monorepo project structures by pinning version dependencies when building and publishing archives with local path dependencies to other Poetry projects within the same monorepo.

Installation

poetry self add poetry-monorepo-dependency-plugin

If you want to activate poetry-monorepo-dependency-plugin for all build, publish, and export command invocations, add the following to your project's pyproject.toml that has path dependencies to other Poetry projects:

[tool.poetry-monorepo-dependency-plugin]
enable = true

Usage

During archive building or publishing, this plugin will rewrite path dependencies to other Poetry projects using the corresponding pinned version dependency extracted from the referenced project's pyproject.toml. The extracted dependency version will be applied to the generated archive using the strategy specified in the version-pinning-strategy configuration. By referencing pinned version dependencies in published archive files, package consumers may more easily depend on and install packages that are built within complex monorepos, without needing to replicate the exact folder structure utilized within the monorepo for that project's dependencies.

For example, assume that spam and ham Poetry projects exist within the same monorepo and use the following pyproject.toml configurations.

spam/pyproject.toml:

[tool.poetry]
name = "spam"
version = "0.1.0"

[tool.poetry.dependencies]
ham = {path = "../ham", develop = true}

ham/pyproject.toml:

[tool.poetry]
name = "ham"
version = "1.2.3"

When generating wheel or sdist archives for the spam project through Poetry's build or publish commands, the corresponding spam package will be constructed as if its dependency on the ham project were declared as ham = "1.2.3". As a result, package metadata in archives for spam will shift from Requires-Dist: ham @ ../ham to Requires-Dist: ham (==1.2.3)

Additionally, to address path dependencies not being portable, this plugin provides the ability to extend Poetry's export command using the export-without-path-deps command. This command will exclude path dependencies from being written to intermediate requirements.txt export. When installing the exported requirements.txt on another machine and/or Docker container local Paths dependencies can not be resolved and therefore can not be installed so they are removed.

Command line mode

If you need greater control over when poetry-monorepo-dependency-plugin is activated, this plugin exposes new build-rewrite-path-deps and publish-rewrite-path-deps Poetry commands for on-demand execution. For example, it may be desirable to only use this plugin during CI to support a monorepo's artifact deployment and/or release process. When these custom Poetry commands are invoked, any configuration defined in the project's pyproject.toml [tool.poetry-monorepo-dependency-plugin] section is ignored and all options (other than enable) are exposed as command line options. For example:

poetry build-rewrite-path-deps --version-pinning-strategy=semver

To generate a requirements.txt without path dependencies use the export-without-path-deps. For example:

poetry export-without-path-deps -f requirements.txt --output requirements.txt

Configuration

The following configuration options are supported within your project's pyproject.toml configuration:

  • [tool.poetry-monorepo-dependency-plugin]: Parent-level container for plugin
    • enable (boolean, default: false): Since Poetry plugins are globally installed, this configuration allows projects to opt-in to this plugin's modifications of the archives built and/or published Poetry
    • version-pinning-strategy (string, default: mixed, options: mixed, semver, exact): Strategy by which path dependencies to other Poetry projects will be versioned in generated archives. Given a path dependency to a Poetry project with version 1.2.3, the version of the dependency referenced in the generated archive is ^1.2.3 for semver and =1.2.3 for exact. mixed mode switches versioning strategies based on whether the dependency Poetry project version is an in-flight development version or a release - if a development version (i.e. 1.2.3.dev456), a variant of semver is used that applies an upper-bound of the next patch version (i.e. >=1.2.3.dev,<1.2.4), and if a release version (i.e. 1.2.3), exact is applied (i.e. =1.2.3).

Licence

poetry-monorepo-dependency-plugin is available under the MIT licence.

Releasing to PyPI

Releasing poetry-monorepo-dependency-plugin relies on the maven-release-plugin to automate manual release activities and Habushu to automate the execution of a Poetry-based DevOps workflow via a custom Maven lifecycle. During Maven's deploy phase, the appropriate plugin packages will be published to PyPI.

A PyPI account with access to the poetry-monorepo-dependency-plugin project is required. PyPI account credentials should be specified in your settings.xml under the <id>pypi</id> <server> entry:

<settings>
  <servers>
    <server>
      <id>pypi</id>
      <username>pypi-username</username>
      <password>{encrypted-pypi-password}</password>
    </server>
  </servers>
</settings>

Execute mvn release:clean release:prepare, answer the prompts for the versions and tags, and execute mvn release:perform to publish the package to PyPI.

Metadata

Release files for poetry-monorepo-dependency-plugin 1.4.0

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-monorepo-dependency-plugin 1.4.0
File Size Uploaded Provenance Actions
poetry_monorepo_dependency_plugin-1.4.0.tar.gz 11.8 kB Without provenance Details for poetry_monorepo_dependency_plugin-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for poetry-monorepo-dependency-plugin 1.4.0
File Interpreter ABI Platform Actions
poetry_monorepo_dependency_plugin-1.4.0-py3-none-any.whl Python 3 none any Details for poetry_monorepo_dependency_plugin-1.4.0-py3-none-any.whl

Total release size: 24.6 kB

Release files / poetry_monorepo_dependency_plugin-1.4.0.tar.gz

Download URL poetry_monorepo_dependency_plugin-1.4.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7c243ccc760f03ead5d76d0e638c3c40c54a64ebff476b6f1235797bca1a5736
BLAKE2b-256 checksum
How to use checksums
95c59a7e7c23268fa5118d7413fae0d3f74233f993dbc06ce89f2cc042583a72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.12.9 Darwin/25.2.0

Release files / poetry_monorepo_dependency_plugin-1.4.0-py3-none-any.whl

Download URL poetry_monorepo_dependency_plugin-1.4.0-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21755dba019062afdf7c243b5fad17d6e8e594d76b1aa792370b4ad71ccadfdd
BLAKE2b-256 checksum
How to use checksums
4770734e4b76f793b7db47d1857fbfb3bbecaf2921b897149dc3ae9396ba6b95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.12.9 Darwin/25.2.0

Security for poetry-monorepo-dependency-plugin 1.4.0

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