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

BUG: incorrect version number generated in distributions #506

Closed
xypron opened this issue May 12, 2022 · 1 comment
Closed

BUG: incorrect version number generated in distributions #506

xypron opened this issue May 12, 2022 · 1 comment
Labels
question StackOverflow wontfix This is not smth we're going to fix

Comments

@xypron
Copy link

xypron commented May 12, 2022

Debian and Ubuntu user package versions like 8.6.0-ds1 which are fine for *.deb packages but not legal according to PEP440.

In cheroot/init.py:13: the Debian package number is misused as Python package version.

 __version__ = pkg_resources.get_distribution('cheroot').version

This leads to errors like the following

$ python3
>>> import cheroot
>>> print cheroot.__version__
8.6.0+ds1
>>> from distutils.version import StrictVersion
>>> StrictVersion(cheroot.__version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/distutils/version.py", line 40, in __init__
    self.parse(vstring)
  File "/usr/lib/python3.10/distutils/version.py", line 137, in parse
    raise ValueError("invalid version number '%s'" % vstring)
ValueError: invalid version number '8.6.0+ds1'
>>>

It would be preferable to sanitize the string returned by pkg_resources.get_distribution('cheroot').version.

Debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010894
Ubuntu bug: https://bugs.launchpad.net/ubuntu/+source/ceph/+bug/1967139

Best regards

Heinrich

@xypron xypron added bug Something is broken triage labels May 12, 2022
xypron added a commit to xypron/cheroot that referenced this issue May 13, 2022
Closes cherrypy#506

The distribution package number is reused as Python package version.

This leads to errors in distutils.version.StrictVersion like

    ValueError: invalid version number '8.6.0+ds1'

Use a regular expression to extract a valid version number.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
xypron added a commit to xypron/cheroot that referenced this issue May 13, 2022
Closes cherrypy#506

The distribution package number is reused as Python package version.

This leads to errors in distutils.version.StrictVersion like

    ValueError: invalid version number '8.6.0+ds1'

Use a regular expression to extract a valid version number.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
@webknjaz webknjaz added question StackOverflow wontfix This is not smth we're going to fix and removed bug Something is broken triage labels May 18, 2022
@webknjaz
Copy link
Member

webknjaz commented May 18, 2022

but not legal according to PEP440.

This is a misconception. Look into PEP 440, find a "local version" there and you'll see that it's perfectly fine to have it. Moreover, the specific use-case is for downstream packagers to encode their patches like that, or for SCM metadata to be appended. In our case, we rely on setuptools-scm to generate intermediate version numbers which also adds a Git commit sha in some cases.
One exception is that PyPI does not allow packages with such versions to be uploaded but that's about it.

This leads to errors like the following

This is because you used a StrictVersion from the deprecated distutils which only covers a sub-case and doesn't account for all of the things PEP 440 allows. As mentioned in #507 (review), today using the packaging dist is a preferred way of constructing a version object.

Ubuntu bug: https://bugs.launchpad.net/ubuntu/+source/ceph/+bug/1967139

Looking at this, I can say that the bug is not ours. The proper upstream to report it to is Ceph:

   File "/usr/share/ceph/mgr/dashboard/cherrypy_backports.py", line 124, in accept_socket_error_0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question StackOverflow wontfix This is not smth we're going to fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants