TopHome
<2023-12-05 Tue>python

Note on python pip package versions

If you notice the version identifiers of pip packages, especially of things like nightlies, you may realize that it does not meet the typical Semantic Versioning standards. This is because, it turns out, python has its own standard of packaging as documented here.

>>> from packaging.version import parse
>>> parse("2.1.0") > parse("2.2.0")
False # makes sense
>>> parse("2.1.0.dev20231115") > parse("2.1.0")
False # is this correct ???

Turns out that this is expected behaviour as clearly documented in the spec here: https://packaging.python.org/en/latest/specifications/version-specifiers/#summary-of-permitted-suffixes-and-relative-ordering

Basically, the following ordering is always followed for suffixes to any version:

.devN, aN, bN, rcN, <no suffix>, .postN

where dev, alpha, beta, release candidates are marked with suffixes to the same version number.