I recently encountered this, which is very useful, but only for a human-readable perspective.
import vaex vaex.__version__ {'vaex': '4.1.0', 'vaex-core': '4.1.0', 'vaex-viz': '0.5.0', 'vaex-hdf5': '0.7.0', 'vaex-server': '0.4.0', 'vaex-astro': '0.8.0', 'vaex-jupyter': '0.6.0', 'vaex-ml': '0.11.1'}
On Wed, Apr 14, 2021 at 2:01 PM Barney Gale
In my Python projects, I like to provide the version as a tuple which can be used directly for comparison
To add to this, comparing tuples doesn't always work well for projects where multiple release lines are maintained simultaneously, e.g. user-facing changes introduced in minor/point releases across several major versions. People use version numbers in wildly different ways.
Barney
On Wed, 14 Apr 2021 at 13:26, Victor Stinner
wrote: So what do you'all think? After thirteen years, it would be nice to put
On Wed, Apr 14, 2021 at 7:48 AM Christopher Barker
wrote: this to bed. There are two main use cases for versions:
* Display them to the user * Compare versions to check if one is newer, older or the same
I dislike using strings for comparison. You need to use packaging.version for that: https://packaging.pypa.io/en/latest/version.html
Many C libraries provide the version as a number of as 3 numbers (major, minor, micro). In its C API, Python provides all of them:
* PY_VERSION_HEX: single number * (PY_MAJOR_VERSION, PY_MINOR_VERSION, PY_MICRO_VERSION, PY_RELEASE_LEVEL, PY_RELEASE_SERIAL): as 5 numbers * PY_VERSION: string
In my Python projects, I like to provide the version as a tuple which can be used directly for comparison: version_a <= version_b. Example:
VERSION = (2, 2, 1) __version__ = '.'.join(map(str, VERSION))
The tuple might contain strings like "beta" or "rc", as soon as comparison makes sense ;-) Sadly, such tuple is no standardized. Which part is the major version? How to format it as a string?
Good luck with trying to standardize that ;-)
Victor -- Night gathers, and now my watch begins. It shall not end until my death. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/MBBYB5AW... Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/4XWIWIKD... Code of Conduct: http://python.org/psf/codeofconduct/
-- The dead increasingly dominate and strangle both the living and the not-yet born. Vampiric capital and undead corporate persons abuse the lives and control the thoughts of homo faber. Ideas, once born, become abortifacients against new conceptions.