Skip to content

fix LooseVersion when running with Python 2.7#4408

Merged
boegel merged 2 commits intoeasybuilders:developfrom
Flamefire:20231220133211_new_pr_ttolZmNdMU
Dec 20, 2023
Merged

fix LooseVersion when running with Python 2.7#4408
boegel merged 2 commits intoeasybuilders:developfrom
Flamefire:20231220133211_new_pr_ttolZmNdMU

Conversation

@Flamefire
Copy link
Copy Markdown
Contributor

@Flamefire Flamefire commented Dec 20, 2023

(created using eb --new-pr)

I got a failed check:

Version check via nvidia-smi after loading the module failed: Reported CUDA version 11.6 is not 11.6

That can be reproduced with: python2 -c "from easybuild.tools import LooseVersion; print LooseVersion('2.2') != LooseVersion('2.2')" which before this PR returned True

Reason:

  • We didn't have an __ne__ method
  • Our rich compare used internally is named _cmp, Python2 would use __cmp__ automatically for all ops, but Python3 doesn't anymore.
  • Hence != checked for object identity, i.e. the same memory address which is practically never true
  • Python 3 synthesizes __ne__ from __eq__ which is why this almost always worked.

@boegel boegel added the bug fix label Dec 20, 2023
@boegel boegel added this to the next release (4.9.0?) milestone Dec 20, 2023
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
Copy link
Copy Markdown
Member

boegel commented Dec 20, 2023

@Flamefire Thanks for the fix.

Friends don't let friends use Python 2 anymore btw ;)

@boegel boegel changed the title fix LooseVersion on Python2 fix LooseVersion on Python 2.7 Dec 20, 2023
@boegel boegel merged commit 5ee24a7 into easybuilders:develop Dec 20, 2023
@Flamefire
Copy link
Copy Markdown
Contributor Author

Friends don't let friends use Python 2 anymore btw ;)

I know. I had a node where python was still Python 2 and EB_PYTHON=python3 was more or less silently ignored as it resolved to Python 3.4 or so...

@Flamefire Flamefire deleted the 20231220133211_new_pr_ttolZmNdMU branch December 20, 2023 16:34
@boegel boegel changed the title fix LooseVersion on Python 2.7 fix LooseVersion when running with Python 2.7 Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants