Skip to main content

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"))

# Sort keys: encode RPM version ordering into raw bytes.
# Useful in databases (in-database RPM version ordering)
from rpm_version import EvrSortKey
key_a = EvrSortKey.from_values("1", "2.0", "3.fc40")
key_b = EvrSortKey.parse("1:3.0-1.fc40")
assert key_a < key_b
# Evr.sortkey() returns the same thing
assert Evr.parse("1:2.0-3.fc40").sortkey() == key_a
# Use as a sort key for sorted()
sorted(["2.0-1", "1:0.1-1", "1.0-1"], key=EvrSortKey.parse)

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.5.1.tar.gz (29.9 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.5.1-cp310-abi3-win_amd64.whl (168.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

rpm_version-0.5.1-cp310-abi3-manylinux_2_28_x86_64.whl (315.6 kB view details)

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

rpm_version-0.5.1-cp310-abi3-manylinux_2_28_aarch64.whl (312.9 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

rpm_version-0.5.1-cp310-abi3-macosx_11_0_arm64.whl (282.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for rpm_version-0.5.1.tar.gz
Algorithm Hash digest
SHA256 8f55e499bd93d878f98d9cb5e53ccbb19794997941ebd5f3848133a9bdfadb4a
MD5 c22c129017b5fa4eb7aec518eb60a87b
BLAKE2b-256 24f9f4042715f9cba089926c76858c424fd9701b34f55d748a565d9d726abddb

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for rpm_version-0.5.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 78fa7ed2f588a164b87c4ee2e814445aaf4932f3dc82ab82ba07e574e585f1d2
MD5 76ee817beb47844c15e9ed9ed1835612
BLAKE2b-256 9d4503e4e3c0384874100ed308682a157fadc45e58b2262a54a0caf452baf295

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rpm_version-0.5.1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 54619ce73b9b8d23460a5e73fd0be1b3c2923f32252e6b42c4988b91f6ad3102
MD5 b5b9188abd9cb4b83c09bfc71ee8b3bc
BLAKE2b-256 1e5658f114ccd1687d49bd2987bd3c911132d392a5166107e9862c92c535023e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpm_version-0.5.1-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.5.1-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rpm_version-0.5.1-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1381a3dce1713a8320da21e193b95593989b7bf5c01559a81881e0c9f318436f
MD5 e9b1e5905a80ca5be2d9c09c85c17d0b
BLAKE2b-256 265fc7b6c6dd759abac18bf2634a8e9d40b95ff414fbfc91cfebeb9c3e8bc06b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rpm_version-0.5.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fcdb88d85541a54d337daf18070e978f06df653a4ebfb08da0cb9f49cfcb5a59
MD5 a6d6a9d726d26dfbd14d403b2596549a
BLAKE2b-256 285fa90090877736926af5572f45d59155a3f4db3d444c0d6a3556c572af7734

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpm_version-0.5.1-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 Sentry Error logging StatusPage Status page