Skip to content

Fix handling of maximum Python version in pick_python_cmd function in PythonPackage easyblock + require that maximum major Python version is specified if maximum minor Python version is specified#3478

Merged
boegel merged 2 commits intoeasybuilders:developfrom
Flamefire:fix-max-pyver
May 23, 2025

Conversation

@Flamefire
Copy link
Contributor

@Flamefire Flamefire commented Oct 11, 2024

When the minor version is unset, only the major version must be checked.
Otherwise patch versions etc. must be ignored.
This allows:
3.7.4 for "max_py_majver=3" and "max_py_majver=3 max_py_minver=7"

However I'd argue that our current approach with max_py_maj/minver and req_py_maj/minver is error-prone anyway: It does not make sense to only specify a minor version for either. Hence I'd change that easyconfig parameter into a single one: required_python_version which is a string like "3.7", same for the max version.
This can then be converted to a LooseVersion and fully avoids the possibility of missing major versions as well as having only a single parameter instead of 2. We can convert the current parameters to the new one automatically and deprecate them for 5.1 or IMO better just remove them for 5.0 as currently ReFrame is the only EC using this and it is trivial to update.

@boegel boegel changed the base branch from 5.0.x to develop March 19, 2025 11:13
@boegel boegel added the bug fix label Mar 19, 2025
@boegel boegel added this to the release after 5.0.0 milestone Mar 19, 2025
@boegel
Copy link
Member

boegel commented Mar 19, 2025

@Flamefire I changed to target branch in this PR from 5.0.x to develop, you should synchronize your PR branch with current develop branch (which has received a massive update after the release of EasyBuild v5.0.0, see #3670)

@boegel boegel changed the title Fix handling of maximum python version in pick_python_cmd Fix handling of maximum python version in pick_python_cmd May 23, 2025
@boegel
Copy link
Member

boegel commented May 23, 2025

@Flamefire Can you sync this with develop now that #3432 is merged?

@Flamefire
Copy link
Contributor Author

Rebased which removes the commits contained by the merged PR

@boegel boegel changed the title Fix handling of maximum python version in pick_python_cmd Fix handling of maximum Python version in pick_python_cmd function in PythonPackage easyblock + require that maximum major Python version is specified if maximum minor Python version is specified May 23, 2025
@boegel
Copy link
Member

boegel commented May 23, 2025

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS matplotlib-3.9.2-gfbf-2024a.eb
  • SUCCESS numexpr-2.9.0-foss-2023a.eb

Build succeeded for 2 out of 2 (2 easyconfigs in total)
node3502.doduo.os - Linux RHEL 9.4, x86_64, AMD EPYC 7552 48-Core Processor (zen2), Python 3.9.18
See https://gist.github.com/boegel/25f87d5b01e0ee6d082146b4d2dad216 for a full test report.

Copy link
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

Flamefire added 2 commits May 23, 2025 11:04
When the minor version is unset, only the major version must be checked.
Otherwise patch versions etc. must be ignored.
This allows:
3.7.4 for "max_py_majver=3" and "max_py_majver=3 max_py_minver=7"
@boegel
Copy link
Member

boegel commented May 23, 2025

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS ReFrame-3.0.eb
  • SUCCESS ReFrame-3.11.2.eb
  • SUCCESS ReFrame-3.12.0.eb
  • SUCCESS ReFrame-3.2.eb
  • SUCCESS ReFrame-4.0.1.eb
  • SUCCESS ReFrame-4.0.5.eb
  • SUCCESS ReFrame-4.2.0.eb
  • SUCCESS ReFrame-4.3.2.eb
  • SUCCESS ReFrame-4.3.3.eb
  • SUCCESS ReFrame-4.6.2-GCCcore-12.3.0.eb
  • SUCCESS ReFrame-4.6.2-GCCcore-13.2.0.eb
  • SUCCESS ReFrame-4.6.2.eb
  • SUCCESS ReFrame-4.6.2-Python-3.6.eb
  • SUCCESS ReFrame-4.6.3-GCCcore-13.3.0.eb
  • SUCCESS ReFrame-4.7.4-GCCcore-13.2.0.eb
  • SUCCESS ReFrame-4.7.4-GCCcore-13.3.0.eb
  • SUCCESS ReFrame-4.7.4.eb
  • SUCCESS ReFrame-4.7.4-Python-3.6.eb

Build succeeded for 18 out of 18 (18 easyconfigs in total)
node3502.doduo.os - Linux RHEL 9.4, x86_64, AMD EPYC 7552 48-Core Processor (zen2), Python 3.9.18
See https://gist.github.com/boegel/0c1eea45ab104b4c46875a7923c65108 for a full test report.

@boegel boegel merged commit ae16b78 into easybuilders:develop May 23, 2025
17 checks passed
@Flamefire Flamefire deleted the fix-max-pyver branch May 23, 2025 10:17
@Flamefire
Copy link
Contributor Author

Any thoughts about the proposal? I.e. changing:

- def find_python_cmd(log, req_py_majver, req_py_minver, max_py_majver, max_py_minver, required):
+ def find_python_cmd(log, req_version, max_version):  # Or min_version for req_version

-def pick_python_cmd(req_maj_ver=None, req_min_ver=None, max_py_majver=None, max_py_minver=None):
+def pick_python_cmd(req_version=None, max_version=None):

Usage would then change:

-        self.assertIsNotNone(pick_python_cmd(3, 6))
+        self.assertIsNotNone(pick_python_cmd('3.6'))
-        self.assertIsNotNone(pick_python_cmd(2, 6, 123, 456))
+        self.assertIsNotNone(pick_python_cmd('2.6', '123.456'))

We could keep a deprecation period as the new argument would be strings. A bit harder if we want to support the old keywords, but doable.

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