Skip to main content

pallet-patcher

build coverage pypi

Tools for working with curated collections of Cargo packages

pallet-patcher is a command-line tool designed to compose a collection of locally available Cargo packages that satisfy the dependencies of a given Cargo manifest. It resolves dependencies from provided local search paths, identifying compatible crate versions, and outputs patch arguments or configuration that can be supplied directly to Cargo. This is particularly useful for building Cargo projects in offline environments or working with specific layers of dependencies.

Motivation

Cargo is designed to be highly reliable by ensuring that dependencies are either pulled from a central registry (like crates.io) or explicitly defined by their location (e.g., path = "../my-crate"). While this approach provides great predictability, there are specialized use cases where developers may need more flexibility—specifically, when resolving dependencies from dynamically provided local directories without modifying the original source code.

Other build systems and environments often provide mechanisms to search for dependencies across multiple locations:

  • CMake utilizes CMAKE_PREFIX_PATH for package discovery.

  • pkg-config leverages PKG_CONFIG_PATH to locate libraries.

  • Python uses PYTHONPATH to find modules.

pallet-patcher provides a similar workflow for the Cargo ecosystem. It is particularly useful for complex development environments where projects are composed from multiple independent local layers or for building in restricted, offline environments where dependency sources are managed externally.

By scanning a list of search paths and resolving compatible crate versions using standard SemVer rules, pallet-patcher dynamically generates the necessary Cargo configuration to patch dependencies with their discovered local counterparts. This provides a bridge between Cargo’s strict dependency management and the need for dynamic, path-based discovery in specific workflows.

Usage

usage: pallet-patcher [-h] [--output-format {args,toml}]
                      manifest_path search_path [search_path ...]

positional arguments:
  manifest_path         Path to the Cargo.toml file on disk
  search_path           List of local registry sources to search for packages

options:
  -h, --help            show this help message and exit
  --output-format {args,toml}
                        Choose the output format for Cargo configuration. 'args' (default)
                        for CLI arguments, or 'toml' for configuration file contents.

Example

Generate Cargo command-line arguments to patch dependencies using locally available crates:

pallet-patcher Cargo.toml /usr/share/cargo/registry ../another/path

Output:

--config=patch.'crates-io'.'pkg::0.1.0'.package='pkg'
--config=patch.'crates-io'.'pkg::0.1.0'.path='/path/to/local/crates/pkg'

Generate a TOML configuration for your .cargo/config.toml:

pallet-patcher --output-format toml Cargo.toml /usr/share/cargo/registry > .cargo/config.toml

Output:

[patch.'crates-io'.'pkg::0.1.0']
package = 'pkg'
path = '/usr/share/cargo/registry/pkg'

Metadata

Release files for pallet-patcher 0.3.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 pallet-patcher 0.3.0
File Size Uploaded
pallet_patcher-0.3.0.tar.gz 21.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pallet-patcher 0.3.0
File Interpreter ABI Platform
pallet_patcher-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.1 kB

Release files / pallet_patcher-0.3.0.tar.gz

Download URL pallet_patcher-0.3.0.tar.gz
Size 21.5 kB
Tags Source
SHA-256 checksum
How to use checksums
21ac1d43a4543cb4fc53774dcbff48aeccc183017b8b4045a060708a2dbbc46d
BLAKE2b-256 checksum
How to use checksums
0a0b7dbbfb429f8a321982f01a8ea12fb2271225e09755b0b2ab96ea41166b89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/59.8.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release files / pallet_patcher-0.3.0-py3-none-any.whl

Download URL pallet_patcher-0.3.0-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ec69eca049411d89a2084ae3f4063a1dac046019af5747b695d140cf0188c34
BLAKE2b-256 checksum
How to use checksums
56d250586487d62a52e354b2cec0767163a489ba6c8a79428027eccd1f6f6761
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/59.8.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

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