Expand description
A library for python version numbers and specifiers, implementing PEP 440
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 pre-releases
- dev versions, which can be attached to both table releases and pre-releases. When attached to a pre-release the dev version is ordered just below the normal pre-release, however when attached to a stable version, the dev version is sorted before a pre-releases
- pre-release 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
- pre-release vs. pre-release 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.0when sorting, but==1.0matches1.0+local. While the ordering of versions itself is a total order the version matching needs to catch all sorts of special cases
Structs§
- Operator
Parse Error - An error that occurs when parsing an invalid version specifier operator.
- Prerelease
- An optional pre-release modifier and number applied to a version.
- Tilde
Version Specifier - A simple
~=version specifier with a major, minor and (optional) patch version, e.g.,~=3.13or~=3.13.0. - Version
- A version number such as
1.2.3or4!5.6.7-a8.post9.dev0. - Version
Parse Error - An error that occurs when parsing a
Versionstring fails. - Version
Pattern - A version number pattern.
- Version
Pattern Parse Error - An error that occurs when parsing a
VersionPatternstring fails. - Version
Specifier - A version range such as
>1.2.3,<=4!5.6.7-a8.post9.dev0or== 4.1.*. Parse withVersionSpecifier::from_str - Version
Specifier Build Error - An error that can occur when constructing a version specifier.
- Version
Specifiers - Sorted version specifiers, such as
>=2.1,<3. - Version
Specifiers Parse Error - Error with span information (unicode width) inside the parsed line
Enums§
- Bump
Command - Various ways to “bump” a version
- Local
Segment - A part of the local version identifier
- Local
Version - Either a sequence of local segments or [
LocalVersion::Sentinel], an internal-only value that compares greater than all other local versions. - Local
Version Slice - Like
LocalVersion, but using a slice - Operator
- One of
~===!=<=>=<>=== - Prerelease
Kind - Optional pre-release modifier (alpha, beta or release candidate) appended to version
Statics§
- MIN_
VERSION - The minimum version that can be represented by a
Version:0a0.dev0.