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

version.parse compares differently than distutils.version #514

Closed
cbrnr opened this issue Mar 1, 2022 · 3 comments
Closed

version.parse compares differently than distutils.version #514

cbrnr opened this issue Mar 1, 2022 · 3 comments

Comments

@cbrnr
Copy link

cbrnr commented Mar 1, 2022

Because distutils.version is deprecated and explicitly recommends to use packaging.version, we've recently switched to the latter. Unfortunately, comparing versions works differently (example from mne-tools/mne-python#10404):

>>> from distutils.version import LooseVersion
>>> LooseVersion('1.0.dev0') >= LooseVersion('1.0')
<stdin>:1: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
True
>>> from packaging.version import parse
>>> parse("1.0.dev0") >= parse("1.0")
False

Is there something I'm missing?

@pradyunsg
Copy link
Member

pradyunsg commented Mar 1, 2022

This is expected. packaging.version uses PEP 440-specified rules for comparing versions. distutils.version has its own custom logic that isn't really mirrored anywhere, as far as I know.

See #321 for the discussion on dropping LegacyVersion from packaging (which is closer to distutils.version, and similarly wonky), and #502 and #501 (comment) for other users who are also migrating away from distutils.version.

@cbrnr
Copy link
Author

cbrnr commented Mar 1, 2022

Thanks @pradyunsg! So we'd better update the code on our side then.

@cbrnr cbrnr closed this as completed Mar 1, 2022
@brettcannon brettcannon pinned this issue Mar 1, 2022
@brettcannon
Copy link
Member

I've pinned this issue to help folks who come asking about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants