Skip to main content

A library for python version numbers and specifiers, implementing PEP 440

Project description

PEP440 in rust

A library for python version numbers and specifiers, implementing PEP 440

pip install pep440_rs
from pep440_rs import Version, VersionSpecifier

assert Version("1.1a1").any_prerelease()
assert Version("1.1.dev2").any_prerelease()
assert not Version("1.1").any_prerelease()
assert VersionSpecifier(">=1.0").contains(Version("1.1a1"))
assert not VersionSpecifier(">=1.1").contains(Version("1.1a1"))
assert Version("2.0") in VersionSpecifier("==2")

Unlike pypa/packaging, this library always matches preleases. To only match final releases, filter with .any_prelease() beforehand.

PEP 440 has a lot of unintuitive features, including:

  • An epoch that you can prefix the version which, e.g. 1!1.2.3. Lower epoch always means lower version (1.0 <=2!0.1)
  • post versions, which can be attached to both stable releases and prereleases
  • dev versions, which can be attached to sbpth table releases and prereleases. When attached to a prerelease the dev version is ordered just below the normal prerelease, however when attached to a stable version, the dev version is sorted before a prereleases
  • prerelease handling is a mess: "Pre-releases of any kind, including developmental releases, are implicitly excluded from all version specifiers, unless they are already present on the system, explicitly requested by the user, or if the only available version that satisfies the version specifier is a pre-release.". This means that we can't say whether a specifier matches without also looking at the environment
  • prelease vs. prerelease incl. dev is fuzzy
  • local versions on top of all the others, which are added with a + and have implicitly typed string and number segments
  • no semver-caret (^), but a pseudo-semver tilde (~=)
  • ordering contradicts matching: We have e.g. 1.0+local > 1.0 when sorting, but ==1.0 matches 1.0+local. While the ordering of versions itself is a total order the version matching needs to catch all sorts of special cases

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

pep440_rs-0.6.0.tar.gz (48.7 kB view hashes)

Uploaded Source

Built Distributions

pep440_rs-0.6.0-cp38-abi3-win_amd64.whl (176.1 kB view hashes)

Uploaded CPython 3.8+ Windows x86-64

pep440_rs-0.6.0-cp38-abi3-musllinux_1_2_x86_64.whl (441.7 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ x86-64

pep440_rs-0.6.0-cp38-abi3-musllinux_1_2_i686.whl (466.4 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ i686

pep440_rs-0.6.0-cp38-abi3-musllinux_1_2_armv7l.whl (594.2 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ ARMv7l

pep440_rs-0.6.0-cp38-abi3-musllinux_1_2_aarch64.whl (509.4 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ ARM64

pep440_rs-0.6.0-cp38-abi3-manylinux_2_34_x86_64.whl (270.2 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.34+ x86-64

pep440_rs-0.6.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (392.6 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ s390x

pep440_rs-0.6.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (361.4 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ppc64le

pep440_rs-0.6.0-cp38-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (373.6 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ppc64

pep440_rs-0.6.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (332.0 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

pep440_rs-0.6.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (330.6 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

pep440_rs-0.6.0-cp38-abi3-macosx_10_12_x86_64.whl (241.7 kB view hashes)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

pep440_rs-0.6.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (474.1 kB view hashes)

Uploaded CPython 3.8+ macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page