Package: poetry-monorepo-dependency-plugin
Poetry Monorepo Dependency PluginForked and inspired by thepoetry-stickywheel-plugin, thisPoetryplugin 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.Installationpoetry self add poetry-monorepo-dependency-pluginIf you want to activatepoetry-monorepo-dependency-pluginfor allbuildandpublishcommand invocations, add the following to your project'spyproject.tomlthat has path dependencies to other Poetry projects:[tool.poetry-monorepo-dependency-plugin]enable=trueUsageDuring archive building or publishing, this plugin will rewritepath dependenciesto other Poetry projects using the corresponding pinned version dependency extracted from the referenced project'spyproject.toml.
The extracted dependency version will be applied to the generated archive using the strategy specified in theversion-pinning-strategyconfiguration.  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 thatspamandhamPoetry projects exist within the same monorepo and use the followingpyproject.tomlconfigurations.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 generatingwheelorsdistarchives for thespamproject through Poetry'sbuildorpublishcommands, the correspondingspampackage will be constructed as if its dependency on thehamproject were declared asham = "1.2.3".  As a result, package metadata in archives forspamwill shift fromRequires-Dist: ham @ ../hamtoRequires-Dist: ham (==1.2.3)Command line modeIf you need greater control over whenpoetry-monorepo-dependency-pluginis activated, this plugin exposes newbuild-rewrite-path-depsandpublish-rewrite-path-depsPoetry 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'spyproject.toml[tool.poetry-monorepo-dependency-plugin]section is ignored and all options
(other thanenable) are exposed as command line options.  For example:poetry build-rewrite-path-deps --version-pinning-strategy=semverConfigurationThe following configuration options are supported within your project'spyproject.tomlconfiguration:[tool.poetry-monorepo-dependency-plugin]: Parent-level container for pluginenable(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 Poetryversion-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 version1.2.3, the version of the dependency referenced in the generated archive is^1.2.3forsemverand=1.2.3forexact.mixedmode 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 ofsemveris 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),exactis applied (i.e.=1.2.3).Licencepoetry-monorepo-dependency-pluginis available under theMIT licence.Releasing to PyPIReleasingpoetry-monorepo-dependency-pluginrelies on themaven-release-pluginto automate manual release activities andHabushuto automate the execution of a
Poetry-based DevOps workflow via a custom Maven lifecycle.  During Maven'sdeployphase, the appropriate plugin packages
will be published to PyPI.APyPI accountwith access to thepoetry-monorepo-dependency-pluginproject is required. PyPI account credentials should be specified in yoursettings.xmlunder the<id>pypi</id><server>entry:<settings><servers><server><id>pypi</id><username>pypi-username</username><password>{encrypted-pypi-password}</password></server></servers></settings>Executemvn release:clean release:prepare, answer the prompts for the versions and tags, and executemvn release:performto publish
the package to PyPI.