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.4.0.tar.gz (20.1 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.4.0-cp310-abi3-win_amd64.whl (166.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

rpm_version-0.4.0-cp310-abi3-manylinux_2_28_x86_64.whl (314.8 kB view details)

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

rpm_version-0.4.0-cp310-abi3-macosx_11_0_arm64.whl (276.9 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: rpm_version-0.4.0.tar.gz
  • Upload date:
  • Size: 20.1 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.4.0.tar.gz
Algorithm Hash digest
SHA256 0dca8f1ea111276e6f9f65b8a72ee0e78442e3a2ce80028efb1d1f42b60459a5
MD5 2ce5876650285384730d212bb364085f
BLAKE2b-256 c24b2083d58cbcfc277680e376373b0ae1526ff0960f29b1c8fcdf48b3ae402a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpm_version-0.4.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.4.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: rpm_version-0.4.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 166.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.4.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 71e3a0ebe39a7e16ac20bf3fb7214742c186b27168ce514e9ebceb3792fbaf54
MD5 80223ab9138420160a9b5cc7de5fc1f9
BLAKE2b-256 47097b1e260abfb25c15a04eefcc4dd294771f9169a0ffe94dbdb04e06b3f921

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpm_version-0.4.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.4.0-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rpm_version-0.4.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d0da9ef9a948ff0af55795fce59de14a6d0948c1824e863f993ba01e8cf952a4
MD5 8352489212bdee9ca5470887fb6a19ba
BLAKE2b-256 02f266eaa4da13c4c3e5f2cef72d39106ef447c4b57389231dbca274eb7688ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpm_version-0.4.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.4.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rpm_version-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b7f15538ad9e61fdc6d7d31ad22a5f6f9ff19dd78535ac625a33346e6348bd1d
MD5 e0f56fdabe8d81da28ef85d1ed67d282
BLAKE2b-256 a2d0bd61ed8c1187eaee5e5fdd815a0bc7c7bcfd6d1109cda4b687c190a19e15

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpm_version-0.4.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