Skip to main content

pubgrub-py

Python bindings for the PubGrub version resolution algorithm.

PubGrub is the dependency resolution algorithm used by Dart's pub package manager, and this library provides Python access to the Rust implementation for high-performance dependency resolution.

Installation

pip install pubgrub-py

Or with maturin for development:

cd packages/pubgrub-py
maturin develop

Usage

Simple API

from pubgrub_py import resolve

# Define available packages with their versions and dependencies
available = {
    "app": {
        "1.0.0": {"lib-a": ">=1.0.0", "lib-b": ">=2.0.0"},
    },
    "lib-a": {
        "1.0.0": {},
        "1.1.0": {"shared": ">=1.0.0"},
    },
    "lib-b": {
        "2.0.0": {"shared": ">=1.0.0"},
        "2.1.0": {"shared": ">=1.5.0"},
    },
    "shared": {
        "1.0.0": {},
        "1.5.0": {},
        "2.0.0": {},
    },
}

# Resolve dependencies
result = resolve(
    requirements={"app": ">=1.0.0"},
    available=available,
)
# Returns: {"app": "1.0.0", "lib-a": "1.1.0", "lib-b": "2.1.0", "shared": "2.0.0"}

Resolver Class API

For more control, use the Resolver class directly:

from pubgrub_py import Resolver, ResolutionError

resolver = Resolver()

# Add packages one by one
resolver.add_package("app", "1.0.0", {"lib": ">=1.0.0"})
resolver.add_package("lib", "1.0.0", {})
resolver.add_package("lib", "2.0.0", {})

# Resolve
try:
    result = resolver.resolve({"app": ">=1.0.0"})
    print(result)  # {"app": "1.0.0", "lib": "2.0.0"}
except ResolutionError as e:
    print(f"Resolution failed: {e}")

Version Constraint Syntax

This library supports PEP 440 version specifiers:

Operator Example Meaning
>= >=1.0.0 Greater than or equal
<= <=2.0.0 Less than or equal
> >1.0.0 Greater than
< <2.0.0 Less than
== ==1.5.0 Exact match
!= !=1.3.0 Not equal
~= ~=1.4.0 Compatible release (>=1.4.0,<1.5.0)

Combined constraints are separated by commas: >=1.0.0,<2.0.0

Error Handling

When resolution fails, ResolutionError is raised with a human-readable explanation:

from pubgrub_py import resolve, ResolutionError

try:
    resolve(
        requirements={"a": ">=1.0.0", "b": ">=1.0.0"},
        available={
            "a": {"1.0.0": {"shared": ">=2.0.0"}},
            "b": {"1.0.0": {"shared": "<2.0.0"}},
            "shared": {"1.0.0": {}, "2.0.0": {}},
        },
    )
except ResolutionError as e:
    print(e)
    # Output explains the conflict:
    # "Because a 1.0.0 depends on shared >=2.0.0
    #  and b 1.0.0 depends on shared <2.0.0,
    #  a 1.0.0 and b 1.0.0 are incompatible."

Development

Building

# Install maturin
pip install maturin

# Build and install in development mode
cd packages/pubgrub-py
maturin develop

# Build release wheel
maturin build --release

Testing

# Run Python tests
pytest tests/

# Run Rust tests
cargo test

License

MIT

Metadata

Release files for pubgrub-py 1.1.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 pubgrub-py 1.1.0
File Size Uploaded Provenance Actions
pubgrub_py-1.1.0.tar.gz 11.5 kB With provenance Details for pubgrub_py-1.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pubgrub-py 1.1.0
File Actions
pubgrub_py-1.1.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for pubgrub_py-1.1.0-cp312-cp312-win_amd64.whl
pubgrub_py-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for pubgrub_py-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pubgrub_py-1.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details for pubgrub_py-1.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
pubgrub_py-1.1.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for pubgrub_py-1.1.0-cp312-cp312-macosx_11_0_arm64.whl
pubgrub_py-1.1.0-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details for pubgrub_py-1.1.0-cp312-cp312-macosx_10_12_x86_64.whl

Total release size: 1.8 MB

Release files / pubgrub_py-1.1.0.tar.gz

Download URL pubgrub_py-1.1.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bd9efb1b3152262ae5790cf07ca2ef5ccc83c13f26719223952505f7c015e492
BLAKE2b-256 checksum
How to use checksums
2a069632c46b33e23bd852fe3b718e4434477f0024fe8f36aa84cdaae8828c75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

Release files / pubgrub_py-1.1.0-cp312-cp312-win_amd64.whl

Download URL pubgrub_py-1.1.0-cp312-cp312-win_amd64.whl
Size 253.0 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a41ad1259d21688728213ab0054eae7f8f2cfdc5bd13ebc9b39a60cfc3c188f9
BLAKE2b-256 checksum
How to use checksums
d5d31c5dd85ce2d8c84ea88f3278ec96999527af3b439e2bc93a6482d29c6480
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

Release files / pubgrub_py-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pubgrub_py-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 410.2 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
daf69cedc85f08ff8315c42afd01f3ee5ccdc4ef31d5d3c6458b424fe509afd3
BLAKE2b-256 checksum
How to use checksums
a67a2aa052a3407d0b476534dce3399ef5d1e0b2e03ce8b41c5c5b6243356c6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

Release files / pubgrub_py-1.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pubgrub_py-1.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 398.6 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
299ce62cf23c8a4c37a7b7b496e9f41641c0d700e37057b51982c97b4e56c3b3
BLAKE2b-256 checksum
How to use checksums
b21fcedd2c4c68a7905b17af1bb4969f3ca980197239618adff2ed26365aaaf7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

Release files / pubgrub_py-1.1.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL pubgrub_py-1.1.0-cp312-cp312-macosx_11_0_arm64.whl
Size 357.3 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
effcd01962189a43943b5a6f6e85721d95a6ba09be498d51d4d53bfe546b62af
BLAKE2b-256 checksum
How to use checksums
e2fc242bfd3ffece12bd9a4b6ac575a379bcd7735e326826e79a0f2720ef3ad7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

Release files / pubgrub_py-1.1.0-cp312-cp312-macosx_10_12_x86_64.whl

Download URL pubgrub_py-1.1.0-cp312-cp312-macosx_10_12_x86_64.whl
Size 365.6 kB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f42545f6f3edffa8106d17b57a17ec78a5450a1af38d6b42bd1d68cf0c1cc6bf
BLAKE2b-256 checksum
How to use checksums
43060364cbd741121d7388b935cf932d9ea3b724aa893ca6bb73c09bfcde34df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

Security for pubgrub-py 1.1.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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for pubgrub_py-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

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