Skip to main content

A library for dealing with RPM versions (NEVRA, EVR) correctly. Python bindings for the Rust crate rpm-version

Project description

Description

A library for dealing with RPM versions (NEVRA, EVR) correctly. Sort algorithm is identical to RPM.

Usage

from rpm_version import Evr, Nevra, evr_compare, evr_sort, nevra_sort

# Compare EVR strings directly
assert evr_compare("1.2.3-4", "1.2.3-5") == -1
assert evr_compare("2:1.0-1", "1:9.9-1") == 1

# Or use the Evr object for structured comparisons
v1 = Evr.parse("1:2.3.4-5")
v2 = Evr.parse("1:2.3.4-6")
assert v1 < v2

# Full NEVRA (Name-Epoch-Version-Release-Architecture) parsing
nevra = Nevra.parse("foo-1:2.3.4-5.x86_64")
print(f"{nevra.name} {nevra.version} {nevra.arch}")  # foo 2.3.4 x86_64

# Tilde (~) denotes a pre-release: sorts before the version without it
assert Evr.parse("1.0~rc1-1") < Evr.parse("1.0-1")
# Caret (^) denotes a post-release snapshot: sorts after the base version
assert Evr.parse("1.0-1") < Evr.parse("1.0^git1-1")
assert Evr.parse("1.0^git1-1") < Evr.parse("1.1-1")

# Bulk sorting entirely in Rust (avoids per-comparison FFI overhead)
sorted_versions = evr_sort(["2.0-1", "1.0-1", "1:0.5-1", "3.0-1"])
assert sorted_versions == ["1.0-1", "2.0-1", "3.0-1", "1:0.5-1"]

sorted_packages = nevra_sort(["foo-2.0-1.x86_64", "bar-1.0-1.x86_64", "foo-1.0-1.x86_64"])
assert sorted_packages == ["bar-1.0-1.x86_64", "foo-1.0-1.x86_64", "foo-2.0-1.x86_64"]

# Evr and Nevra are hashable
seen = {nevra}

# Version requirement matching
from rpm_version import Requirement, ReqOperator
req = Requirement("foo", ReqOperator.GE, Evr.parse("2.0-1"))
assert req.satisfies("foo", Evr.parse("2.0-1"))
assert req.satisfies("foo", Evr.parse("3.0-1"))
assert not req.satisfies("foo", Evr.parse("1.0-1"))

# String operators also work
req = Requirement("foo", ">=", Evr.parse("2.0-1"))

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

rpm_version-0.3.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distributions

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

rpm_version-0.3.0-cp310-abi3-win_amd64.whl (165.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

rpm_version-0.3.0-cp310-abi3-manylinux_2_28_x86_64.whl (313.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

rpm_version-0.3.0-cp310-abi3-macosx_11_0_arm64.whl (275.5 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file rpm_version-0.3.0.tar.gz.

File metadata

  • Download URL: rpm_version-0.3.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rpm_version-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e51c443cccc61b224e1dc1f45ccddb2d7e61e875a4abe4d0603b2d64feb744ff
MD5 93ffff89e12cd91ec51972e27e9d0c93
BLAKE2b-256 47db91633abb36aeb683a9311b5f711caf29ab804ca535b937cc2d216007a9cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpm_version-0.3.0.tar.gz:

Publisher: release.yml on rpm-rs/rpm-version

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rpm_version-0.3.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: rpm_version-0.3.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 165.4 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rpm_version-0.3.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f37a712d7cbb205aa0a4144b04ecf488c3dd4857218ad9d2783825a96f60021f
MD5 c799789ee9ef69763a34c41c4f6e9b4b
BLAKE2b-256 d6e9bd0c9bfdf87b46097510dfb039af7611af4119fb293e2c8ac9fa40e0069c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpm_version-0.3.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on rpm-rs/rpm-version

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rpm_version-0.3.0-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rpm_version-0.3.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5461ed62075d2b50482a16ea5d535a5ad9611a4f7d3e611bcddaf97452c5192
MD5 268c6193ff646cbc873f5363aaca637e
BLAKE2b-256 6bbebd8ced1ee6b4629bdc530affc5ec6d0398ae905905fbc55ab05364a43844

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpm_version-0.3.0-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on rpm-rs/rpm-version

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rpm_version-0.3.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rpm_version-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1e4c1ae8e32f31269e485a1df6ab5a0005fd0e727919cb97dd3ff1c2afd28f0
MD5 d80683b72d1a27ed8a4889a7f574cf5d
BLAKE2b-256 ab90fdec42e7efad7486841b5cff8909ea9f461e73d3f09a5d6fe197b511f417

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpm_version-0.3.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on rpm-rs/rpm-version

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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