Metadata-Version: 2.4
Name: larzsemver
Version: 0.1.0
Summary: Semantic Versioning 2.0.0 in pure Python: parse, compare (spec precedence), sort, bump, and range matching (caret/tilde/x-ranges). Zero dependencies.
Author: larz-scripter
License: MIT
Project-URL: Homepage, https://github.com/larz-scripter/larzsemver
Project-URL: Repository, https://github.com/larz-scripter/larzsemver
Project-URL: Issues, https://github.com/larz-scripter/larzsemver/issues
Keywords: semver,semantic-versioning,version,versioning,version-range,parsing,compare,zero-dependency
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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`.

```python
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

```bash
pip install larzsemver
```

## Usage

```python
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

```bash
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](https://github.com/larz-scripter).

## License

MIT (c) larz-scripter
