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
Conversation
|
@Flamefire I changed to target branch in this PR from |
pick_python_cmd
|
@Flamefire Can you sync this with |
|
Rebased which removes the commits contained by the merged PR |
pick_python_cmdpick_python_cmd function in PythonPackage easyblock + require that maximum major Python version is specified if maximum minor Python version is specified
|
Test report by @boegel Overview of tested easyconfigs (in order)
Build succeeded for 2 out of 2 (2 easyconfigs in total) |
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"
|
Test report by @boegel Overview of tested easyconfigs (in order)
Build succeeded for 18 out of 18 (18 easyconfigs in total) |
|
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. |
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/minverandreq_py_maj/minveris 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_versionwhich is a string like "3.7", same for the max version.This can then be converted to a
LooseVersionand 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.pip checkonly once forPythonBundle#3432