Skip to main content

PyPI PyPI - Python Version PyPI - Wheel License

DEPRECATION NOTICE

Warning - this plugin has been deprecated. Developers should instead consider using the poetry-monorepo-dependency-plugin to support deploying and releasing Poetry projects with path-based dependencies on other Poetry projects within a monorepo.

Overview

poetry-lock-groups-plugin is a lightweight plugin which enables Poetry's dependency group options (--with, --without, --only) when executing the lock command. Broadly, this plugin helps enable a solution pattern that developers may use when working with and releasing packages within a more complex Python monorepo environment that relies on path-based dependencies.

Installation

Execute the following command:

poetry self add poetry-lock-groups-plugin

Use Case

When working within a Python monorepo project structure with local path dependencies, a frequently encountered challenge involves publishing these packages to a PyPI index in a way that can be easily utilized by downstream consumers. Specifically, while editable path dependencies work well to support normal development activities, publishing a package with local path dependencies into a usable sdist or wheel archive typically involves replacing those path dependencies with references to packages that are resolvable within a PyPI repository.

In order to support this scenario, rather than maintaining two distinct versions of pyproject.toml (one with local path dependencies and the other with PyPI resolvable dependencies), developers may leverage dependency groups. Vanilla Poetry recognizes dependency groups only at the install phase - by advancing that recognition to the lock stage, we enable predictable, flexible patterns to support monorepo development.

Example

Given the following pyproject.toml where my-poetry-project depends on common-library within the same monorepo project structure:

[tool.poetry]
name = "my-poetry-project"
version = "0.1.0.dev"
description = ""

[tool.poetry.dependencies]
python = "^3.9"

[tool.poetry.plugins."poetry.application.plugin"]
lock-groups-plugin = "poetry_lock_groups.plugin:LockGroupsPlugin"

[tool.poetry.group.remote.dependencies]
common-library = "^1.2.6"

[tool.poetry.group.local.dependencies]
common-library = {path = "../../common-library/"}

[build-system]
requires = ["poetry-core>=1.2"]
build-backend = "poetry.core.masonry.api"

By running the following command:

poetry lock --with remote --without local

This will generate a poetry.lock file that includes the dependency definitions within the remote group, but without those in the local group. Note that if we included both groups, or simply refrained from specifying group usages, we would see behavior identical to that in vanilla Poetry, which is, in this case, undefined.

Developers will typically execute the following commands as a part of their development workflow while building/testing functionality:

poetry lock --with local --without remote
poetry install --with local --without remote

However, when performing releases, developers will execute the following to ensure that local path dependencies are removed from archives that are published to the configured PyPI repository:

poetry lock --with remote --without local
poetry install --with remote --without local

Consider using Habushu to codify and automate this workflow!

Usage Considerations

Note that the following sequence of commands may fail:

poetry lock --without local
poetry install --with local

This is because the poetry install command searches poetry.lock to install dependencies. By building the lock file without the local group, any dependencies that exist only within that group will have no known sources, rendering them unresolvable.

poetry-lock-groups-plugin only modifies lock operations initiated via the lock command. It makes no attempt to modify behavior resulting from an implied lock, such as when running poetry install without having already created a lock file.

Alternative Approaches

Instead of using dependency groups as described above to capture local path dependencies in a monorepo project, developers may consider using the poetry-stickywheel-plugin or other similar approach to dynamically re-write pyproject.toml on archive deployment with local path dependency declarations appropriately replaced.

Releasing to PyPI

Releasing poetry-lock-groups-plugin leverages the maven-release-plugin to automate release preparation and delegates to the habushu-maven-plugin to publish the package to PyPI during the deploy phase. A PyPI account with access to the poetry-lock-groups-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>pypi-password</password>
    </server>
  </servers>
</settings>

Metadata

Release files for poetry-lock-groups-plugin 1.0.2

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-lock-groups-plugin 1.0.2
File Size Uploaded Provenance Actions
poetry-lock-groups-plugin-1.0.2.tar.gz 4.3 kB Without provenance Details for poetry-lock-groups-plugin-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for poetry-lock-groups-plugin 1.0.2
File Interpreter ABI Platform Actions
poetry_lock_groups_plugin-1.0.2-py3-none-any.whl Python 3 none any Details for poetry_lock_groups_plugin-1.0.2-py3-none-any.whl

Total release size: 9.0 kB

Release files / poetry-lock-groups-plugin-1.0.2.tar.gz

Download URL poetry-lock-groups-plugin-1.0.2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d389af1bc966b71f9598c785a3129c16eee1718a29ce251a897e02502b54aa2c
BLAKE2b-256 checksum
How to use checksums
c9868d781ee9a0f46303264879dc18e5e66ab93d9e4bdfa4e7d319cfe39c5aa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.9.13 Darwin/21.6.0

Release files / poetry_lock_groups_plugin-1.0.2-py3-none-any.whl

Download URL poetry_lock_groups_plugin-1.0.2-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
538857856ce9421b0fbbc28e756deb962a8f4f731adaf60008604ad56982090c
BLAKE2b-256 checksum
How to use checksums
3de6d2534218124de20fd392b853a5b0809b5e196868a17dc32fe1a84bcf9c8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.9.13 Darwin/21.6.0

Security for poetry-lock-groups-plugin 1.0.2

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