Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release candidate tags are sorted as higher than actual releases (0.8.0rc2 >> 0.8.0) #230

Closed
bluca opened this issue Jan 25, 2021 · 7 comments

Comments

@bluca
Copy link
Member

bluca commented Jan 25, 2021

Please use a ~ when appending rcX to a tag. All software that does version comparison will consider 0.8.0 as being lower/older than 0.8.0rc2.

$ dpkg --compare-versions 0.8.0 gt 0.8.0rc2 && echo "true" || echo "false"
false
$ dpkg --compare-versions 0.8.0 gt 0.8.0~rc2 && echo "true" || echo "false"
true
@jiasli
Copy link
Member

jiasli commented Jan 25, 2021

X.YrcN is the correct format according to PEP 440 Pre-releases.

0.8.0 is newer than 0.8.0rc2 in the Python world.

>>> from packaging.version import Version
>>> Version("0.8.0") > Version("0.8.0rc2")
True

@bluca
Copy link
Member Author

bluca commented Jan 25, 2021

Maybe, but not in the rest of the world. dpkg, and probably rpm too, do not follow that custom rule.

@jiasli
Copy link
Member

jiasli commented Jan 25, 2021

If we don't follow PEP 440, installation tools like pip will fail to install the correct version.

This issue has been discussed before: paylogic/py2deb#8.

Also, according to Debian New Maintainers' Guide / 2. First steps / 2.6. Package name and version,

Although this simple approach works most of the time, you may need to adjust package name and upstream version by renaming the upstream source to follow Debian Policy and existing convention.

Also see: Versioning your Python project for Debian

@bluca
Copy link
Member Author

bluca commented Jan 25, 2021

I know perfectly well that there are workarounds, and in fact I am already using them - but they are workarounds, not solutions, that create additional work downstream. Please consider using a scheme that works everywhere, regardless of what PEP440 says, given it's clearly incompatible with what the rest of the world does.

@jiasli
Copy link
Member

jiasli commented Jan 25, 2021

regardless of what PEP440 says

PEP 440 is the official spec of Python versioning. If we don't follow it but switch to Debian versioning, Python's libs will fail to recognize the version:

>>> from packaging.version import Version
>>> Version("0.8.0~rc2")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\<name>\AppData\Local\Programs\Python\Python38\lib\site-packages\packaging\version.py", line 298, in __init__
    raise InvalidVersion("Invalid version: '{0}'".format(version))
packaging.version.InvalidVersion: Invalid version: '0.8.0~rc2'

You may open a discussion on https://discuss.python.org for PEP 440.

@bluca
Copy link
Member Author

bluca commented Jan 25, 2021

There are alternatives that work everywhere. For example, instead of 0.8.0rc1 you could use something like 0.7.999rc1. Then sorting works as expected with all tools.

@jiasli
Copy link
Member

jiasli commented Jan 26, 2021

I understand your concern @bluca. However, as a Python tool, it would be better for us to follow the naming convention of Python community, like other Python tools do.

pip: https://pypi.org/project/pip/#history

image

numpy: https://pypi.org/project/numpy/#history

image

PyYAML: https://pypi.org/project/PyYAML/#history

image

Thanks for the understanding.

@jiasli jiasli closed this as completed Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants