FlexVer
FlexVer is a SemVer-compatible intuitive comparator for free-form versioning strings as seen in the wild. It's designed to sort versions like people do, rather than attempting to force conformance to a rigid and limited standard. This repo collects meta information and discussion on FlexVer, as well as implementations of it in various languages. Notably, it houses a specification.
It works by splitting a string into "numeric" and "non-numeric" parts, and then sorting those
lexically, with a few special cases for SemVer compatibility. This mode of operation is similar to
how sort -V behaves in GNU coreutils. As such, when used solely for simple comparisons and not
group-aware things (such as ~ matches), it is also a stand-in for a SemVer parser (with one
exception — read on)
The initial Java implementation contains a test harness used to initially verify the logic, seen below:
Cyan is numeric, pink is non-numeric, red is SemVer pre-releases, and gray is ignored SemVer-style appendices. As the potential problem space of version number comparisons is infinite, I cannot devise a good way to truly verify this is a completely sound implementation; so, I simply cherry-picked some random examples of versions that I felt would trip up a version comparator, which both do and do not follow SemVer. As such, there are no unit tests; I feel a system like this only benefits from regression tests, after basic sanity tests done during development.
It is a non-goal for comparisons between versions of entirely different structures to "make sense" — but nonetheless, it does try its best and will normalize structural differences and fall back to lexical comparison when all else fails. Fundamentally, FlexVer does not impose any form of restrictions — it will always do its best to compare two strings and never throw an exception. If you do pass two completely different versions to it, well....
...the results won't necessarily make sense. Garbage in, garbage out.
There is one known case where FlexVer and SemVer disagree. It is related to pre-releases, as
they are an exception to the intuitive version flow. There is a special case that makes the most
common forms of them work, such as -pre1, -rc2, -beta.2, etc. However, this works by looking
for a non-numeric component that starts with - and is longer than one character. As such, if you
have a pre-release starting with a numeral, then FlexVer's normal parsing kicks in, which sorts
1.0.0 and 1.0.0-2 in the opposite order that SemVer would. However, I have never seen fully
numeric pre-releases like this in the wild; a hyphenated numeric like that is generally meant to
represent another "group" of versions — in which case, FlexVer does indeed sort it as expected.
Metadata
Release files for flexver 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flexver-1.1.1.tar.gz | 7.1 kB | Without provenance | Details for flexver-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flexver-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for flexver-1.1.1-py3-none-any.whl |
Total release size: 14.8 kB
Release files / flexver-1.1.1.tar.gz
| Download URL | flexver-1.1.1.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c04505632794822dc43c0cc3387be171ae5d054be5c8908a066b058c0982e8a6
|
|
BLAKE2b-256 checksum How to use checksums |
cf952750ae116168dc5cfa49be973d6285be1e4dfebe0b8b3d4fd6a83f9e3a0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.11.4 Windows/10
|
Release files / flexver-1.1.1-py3-none-any.whl
| Download URL | flexver-1.1.1-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9206a83d4a2d111eecad48cb0ae7be52a3b8568d34e0146d54128c580f94f6d9
|
|
BLAKE2b-256 checksum How to use checksums |
76fc23914ec8a6053f5ff6ac935edfa3448b1dbf2be541af0453d0e2ea6fd7d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.11.4 Windows/10
|
Security for flexver 1.1.1
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.