Skip to content

Eliminate use of distutils.version.StrictVersion, use LooseVersion instead#4476

Merged
boegel merged 6 commits intoeasybuilders:5.0.xfrom
bartoldeman:remove-strictversion
Mar 13, 2024
Merged

Eliminate use of distutils.version.StrictVersion, use LooseVersion instead#4476
boegel merged 6 commits intoeasybuilders:5.0.xfrom
bartoldeman:remove-strictversion

Conversation

@bartoldeman
Copy link
Copy Markdown
Contributor

@bartoldeman bartoldeman commented Mar 6, 2024

distutils was removed in Python 3.12. The only reason EasyBuild uses StrictVersion is that it orders beta/rc versions before the released version, unlike LooseVersion. E.g. 5.0.0-beta < 5.0.0 (but > for LooseVersion).

So a new method
is_prerelease(self, other, markers)
was added to LooseVersion to handle that particular case.

Addresses part of #3963

distutils was removed in Python 3.12. The only reason EasyBuild uses
StrictVersion is that it orders beta/rc versions before the released
version, unlike LooseVersion. E.g. 5.0.0-beta < 5.0.0 (but > for
LooseVersion).

So a new method
`is_earlier_or_prerelease(self, other, markers)`
was added to LooseVersion to handle that particular case.

Addresses part of easybuilders#3963
@bartoldeman bartoldeman added this to the 5.0 milestone Mar 6, 2024
In the end this is clearer because we also need to test against a
maximum version (but it is allowed to be a prerelease of that
maximum version, as per StrictVersion semantics!)
@bartoldeman
Copy link
Copy Markdown
Contributor Author

Note that recent Lmod (certainly >=8) doesn't seem to have had any rc versions. The only tmod applicable I can find is 4.0.0-beta. Perhaps we can safely ignore that too, in which case the alternative could be to simply use LooseVersion everywhere...

@bartoldeman bartoldeman added the EasyBuild-5.0 EasyBuild 5.0 label Mar 7, 2024
Comment thread easybuild/tools/modules.py Outdated
Comment thread easybuild/tools/modules.py Outdated
Comment thread easybuild/tools/modules.py Outdated
Comment thread test/framework/modules.py Outdated
Comment thread test/framework/modules.py Outdated
Comment thread test/framework/modules.py Outdated
Comment thread test/framework/modules.py Outdated
Comment thread test/framework/modules.py Outdated
Flip order of `is_prerelease` and version check for clarity.

Co-authored-by: Kenneth Hoste <[email protected]>
Copy link
Copy Markdown
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@boegel boegel merged commit 6203780 into easybuilders:5.0.x Mar 13, 2024
@boegel boegel changed the title Eliminate use of distutils.version.StrictVersion Eliminate use of distutils.version.StrictVersion, use LooseVersion instead Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants