Skip to main content

A uv tool for facilitating the usage of more complex monorepo project structures by pinning version dependencies when building archives with local path dependencies to other uv projects within the same monorepo.

Project description

uv-monorepo-dependency-tool

PyPI PyPI - Python Version PyPI - Wheel PyPI - Downloads License Build uv-monorepo-dependency-tool

Overview

The uv-monorepo-dependency-tool is designed to simplify dependency management in monorepos that utilize path dependencies. It streamlines the process of building archives by rewriting path dependencies to reference the appropriate pinned version dependencies from the referenced project's pyproject.toml.

This helps package consumers avoid replicating complex folder structures within their own projects. Instead, they can directly rely on the pinned version dependencies specified during the archive-building process.

Features

  • Automated Rewrite of Path Dependencies: Converts editable path dependencies into pinned version dependencies during archive generation.
  • Improved Package Metadata: Adjusts dependency metadata in generated archives to use pinned versions, ensuring better compatibility for consumers of the package.
  • Monorepo Support: Designed specifically for managing dependencies across complex UV-based monorepos.
  • CLI Support: Run commands directly from the terminal for seamless integration with your development workflow.

Getting Started

Installation

To use this tool in your environment, from the root project directory run

#TODO: update to published package
uv tool install uv-monorepo-dependency-tool/dist/uv_monorepo_dependency_tool-1.0.0.dev0-py3-none-any.whl 

Usage

The uv-monorepo-dependency-tool works during the archive-building process. It analyzes pyproject.toml files of dependencies in the monorepo and replaces editable path dependencies with the corresponding pinned version dependencies.

For example, assume that project-a and project-a-consumer are uv projects that exist within the same monorepo and use the following pyproject.toml configurations.

project-a/pyproject.toml:

[project]
name = "project-a"
version = "1.0.0.dev0"

project-a-consumer/pyproject.toml:

[project]
name = "project-a-consumer"
version = "1.0.0.dev0"
dependencies = ["project-a"]

[tool.uv.sources]
project-a = { path = "../project-a", editable = true }

When generating wheel or sdist archives for project-a-consumer via build-rewrite-path-deps, the corresponding package-a-consumer source distribution will be constructed as if its dependency on the project-a project were declared as project-a = "1.0.0.dev0". As a result, package metadata in archives for project-a-consumer will shift from Requires-Dist: project-a to Requires-Dist: project-a=="1.0.0.dev0".

Command Line Mode

To execute the tool from the command line, navigate to the desired package directory and run the following command:

uv tool run uv-monorepo-dependency-tool build-rewrite-path-deps --version-pinning-strategy=mixed     

This will generate the updated archive with the rewritten dependencies.

Configuration

The following cli options are supported :

* `--version-pinning-strategy` (`string`, default: `mixed`, options: `mixed`, `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 `exact`.  `mixed` mode switches versioning strategies based on whether the dependency
  UV project version is an in-flight development version or a release - if a development version (i.e. `1.2.3.dev456`),
  `mixed` can be used to specify the inclusion of subsequent dev releases (i.e. `>=1.2.3.dev`), and
  if a release version (i.e. `1.2.3`), `exact` is applied (i.e. `=1.2.3`).

Licence

uv-monorepo-dependency-tool is available under the MIT licence.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uv_monorepo_dependency_tool-1.0.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uv_monorepo_dependency_tool-1.0.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file uv_monorepo_dependency_tool-1.0.1.tar.gz.

File metadata

File hashes

Hashes for uv_monorepo_dependency_tool-1.0.1.tar.gz
Algorithm Hash digest
SHA256 7ef2845f77759dc97383b1d72ded5f31163eca69a1734f099e7617f4380939fd
MD5 6a7b4ee020fd1331ac4022a9a05082ae
BLAKE2b-256 a5c19c97b4058a3856a287a4bb6176fa7ad1da0854586afe4348d3458eec4b89

See more details on using hashes here.

File details

Details for the file uv_monorepo_dependency_tool-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for uv_monorepo_dependency_tool-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53892f31d20ebdac9d762ca7fe8faa810e8d4ef06ae69fddc163ed0a3716dafe
MD5 4e670f5cc3558b03358f97aa2491092a
BLAKE2b-256 233140f378894a7ae4a50644c20ad721f6ddaf456d2f6f109349429656551790

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page