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.2.0.tar.gz (17.7 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.2.0-cp310-abi3-win_amd64.whl (165.2 kB view details)

Uploaded CPython 3.10+Windows x86-64

rpm_version-0.2.0-cp310-abi3-manylinux_2_28_x86_64.whl (313.7 kB view details)

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

rpm_version-0.2.0-cp310-abi3-macosx_11_0_arm64.whl (275.6 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: rpm_version-0.2.0.tar.gz
  • Upload date:
  • Size: 17.7 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.2.0.tar.gz
Algorithm Hash digest
SHA256 a857f74c88db906661fbfed84c8abdba7533aea40f4c2e5fd0fe59e321ccd7b4
MD5 5a5d3d09b8f9eb2ebd3fc31cba546b3e
BLAKE2b-256 02584657f22e687d2db11af21252d9456c4770fd513d1a3eec7ae917c24311e3

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rpm_version-0.2.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 165.2 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.2.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a1bbe85dd573c16ed9d17abe43880481ca3303e9692fbcbdda5bfaf8e01d591b
MD5 7f15a383423644971e646e8978dd4c53
BLAKE2b-256 73d0d5571a9a6cbe47bcc318d51ff4c3472e1df66ff6fe10e58815012fe99652

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rpm_version-0.2.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5785f2ad1a06ba682ac95795e917bc026673db7336aec1c8cb00599b9d7f91b5
MD5 139a7fa905605053eb87daef42f84ee4
BLAKE2b-256 e616aafeafadf4e4880b73c2ab6f9df8a769e1ca8268c199e46cc929da918511

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rpm_version-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b357f08921742432c7ca3d68bf66d48d27d06144363ec85c5871491c90af478
MD5 308ba893d439efc33f26afbc704e3432
BLAKE2b-256 52578b966d10b350dc655f15f3bda57a36bdc1c32597792e20d2237c144e39f1

See more details on using hashes here.

Provenance

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