Uh oh!
There was an error while loading. Please reload this page.
Make Python init more language native - #600
Conversation
daytonb
commented
Nov 14, 2025
At this time there are a couple of issues I know I need to address:
|
xdelaruelle
left a comment
There was a problem hiding this comment.
Many thanks for this pull request. This is already in a very good shape. See review comments for the things to adapt.
Regarding tests:
- the
script/mtutility will guide you to locate where the test failures come from - a
grep -R setbinpath testsuite/run at the root of the repository will help you to see where new tests should be added (you may largely inspire from these setbinpath tests)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
0639451 to
a6b1156Comparedaytonb
commented
Nov 20, 2025
I've addressed the issues noted above except the failing tests. I still need to:
|
a6b1156 to
9ad195bCompare
xdelaruelle
left a comment
There was a problem hiding this comment.
Please see my comments for the few changes to apply.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
daytonb
commented
Nov 22, 2025
I pushed up some fixes. I want to rebase/squash them, but I need to sign off for now. |
Renaming python.py to env_modules.py. On Linux, symlink python.py to point to env_modules.py for backward compatibility. Windows doesn't typically support unix-style symlinks, but we don't need to worry about that since the Windows installations of Environment Modules never had python.py. Signed-off-by: Byron Boulton <bboulton@ara.com>
Signed-off-by: Byron Boulton <bboulton@ara.com> Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Adding the initdir to PYTHONPATH allows users to "import" the "module" function in Python scripts. Signed-off-by: Byron Boulton <bboulton@ara.com>
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
d588c28 to
3a47d8aCompare
xdelaruelle
left a comment
There was a problem hiding this comment.
Many thanks @daytonb for this contribution.
I have extended the documentation and adapted the tests.
I will be able to merge this pull request after CI run.
Uh oh!
There was an error while loading. Please reload this page.
This pull request is an effort to implement a more language-native way to get the "module" function in Python scripts. It is the Python portion of #483. I first proposed this pull request in the mailing list. Below is a description of the plan from that conversation.
For clarity I'll use "Python-module" to refer to a Python script defining functions/classes that you
importin Python code and "environment-module" to refer to a TCL environment module that youmodule load/module unload/etc.The current documentation for Python initialization (https://modules.readthedocs.io/en/latest/module.html#examples-of-initialization) has
A more Pythonic approach would be to
importthismodulefunction somehow. Currently, you can do that with as followsThe issues with this are that you have to modify the
sys.pathinside the script and since the Python-moduleimport-ed is called "python". The name makes it look likemoduleis a function from some core Python-module from the Python project.In this pull request I will
env_module.py(this is what lmod named theirs by the way) andtcl/subcmd.tcl.inadd the folder of initilization scripts to the PYTHONPATH environment variable.These changes would change Python initialization to
which cleans up the way the Python script imports the
modulefunction and communicates more clearly that it comes from a 3rd-party Python-module related to environment modules.