Skip to main content

larzsemver

Semantic Versioning 2.0.0. Pure Python, zero dependencies.

Parse 1.2.3-rc.1+build, compare versions by the exact SemVer precedence rules (including the fiddly pre-release ordering), sort them, bump them, and test whether a version satisfies a range like ^1.2.0 or >=1.2.0 <2.0.0.

from larzsemver import Version, satisfies, max_satisfying

Version.parse("1.2.3") < Version.parse("1.10.0")     # True (numeric, not string!)
satisfies("1.5.2", "^1.2.0")                          # True
satisfies("2.0.0", "^1.2.0")                          # False
max_satisfying(["1.0.0", "1.5.0", "2.0.0"], "^1.0.0") # Version('1.5.0')

Why

  • Spec-correct precedence. 1.10.0 > 1.2.3 (numeric, not lexicographic), and the full pre-release ordering (1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0) - tested against the example in the spec.
  • Range matching. ^ (caret), ~ (tilde), x-ranges (1.2.x), comparators (>=1.0.0 <2.0.0), *, AND (space), and OR (||) - and max_satisfying.
  • Zero dependencies. No semver, no packaging.

Install

pip install larzsemver

Usage

from larzsemver import Version, satisfies, sort_versions, max_satisfying

v = Version.parse("2.1.0-rc.1+build.7")
v.major, v.minor, v.patch, v.prerelease, v.build
v.bump_minor()                          # Version('2.2.0')
sorted([Version.parse("1.0.0"), Version.parse("0.9.0")])

satisfies("1.4.0", "~1.4.0")            # >=1.4.0 <1.5.0
satisfies("1.4.0", ">=1.0.0 <2.0.0 || 3.x")
max_satisfying(available_versions, "^2.0.0")

Tests

python -m unittest discover -s tests -v   # 18 tests incl. the spec precedence chain

The Larz stack

One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.

License

MIT (c) larz-scripter

Metadata

Release files for larzsemver 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for larzsemver 0.1.0
File Size Uploaded Provenance
larzsemver-0.1.0.tar.gz 5.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for larzsemver 0.1.0
File Interpreter ABI Platform
larzsemver-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.3 kB

Release files / larzsemver-0.1.0.tar.gz

Download URL larzsemver-0.1.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bfbf7f782c222037f854cc96a6e9785e8f3d73a8ae5d6e2a33acca0232f2371a
BLAKE2b-256 checksum
How to use checksums
45bdc74a5c2cd1247d473702f91efbe3cd14e316205ac65e3deeb330e8226aca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / larzsemver-0.1.0-py3-none-any.whl

Download URL larzsemver-0.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1febf8fdb19b1f7e2b179fff6384bca3ba3a3b7e48c6619f3351140c01b84e95
BLAKE2b-256 checksum
How to use checksums
de2f1f518e086a8b8cc1e6d3495154e7a75b8732820de61e5e64cc97260b466f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for larzsemver 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page