3 ms·
I wrote a Clojure library that implemented version comparison for all of the package versioning algorithms I could find[1], and by faaar the Python version comp
by djha-skin 3y ago
I wrote a Clojure library that implemented version comparison for all of the package versioning algorithms I could find[1], and by faaar the Python version comparison algorithm was the weirdest, most annoying one to implement (PEP 440[2], the current standard at the time). So many exceptions to the rules that attempt to be helpful but didn't really help.
In my opinion, the best version comparison algorithm is that of the Debian package manager. Super simple, and very flexible. The description of the algorithm fits in just three paragraphs[3]. Most other algorithms implemented in the aforementioned library were actually implemented in terms of it. Prereleases, fourth version numbers, etc. anything you want basically fits nicely in that box.
PEP 440 was the only version comparison algorithm that couldn't be neatly implemented in terms of that of Debian's, beating out semver, maven, and rubygems for complexity.
1: http://djhaskin987.gitlab.io/serovers/index.html http://djhaskin987.gitlab.io/serovers/index.html
2: https://peps.python.org/pep-0440/ https://peps.python.org/pep-0440/
3: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version https://www.debian.org/doc/debian-policy/ch-controlfields.ht...
- woodruffw 3y agoPEP 440 is complicated, but it's also complicated in ways that make sense for a language packaging ecosystem: Debian is tasked primarily with distributing stable builds of software; PyPI is facilitating a source and build distribution relationship between different maintainers and users. In other words: Debian prioritizes unified versioning and has a "fan-out" topology of users; PyPI prioritizes facilitating dependency resolution for a "graph" topology of users.
- djha-skin 3y agoTrue, but I'm also talking about semver, rubygems, and maven algorithms, all of which are also used for languages. It may have been designed for that use case, but so were these others. They also had simpler designs.