Make Python init more language native#600
Draft
daytonb wants to merge 7 commits intoenvmodules:mainfrom
Draft
Conversation
Author
|
At this time there are a couple of issues I know I need to address:
|
xdelaruelle
requested changes
Nov 15, 2025
Collaborator
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)
0639451 to
a6b1156
Compare
Author
|
I've addressed the issues noted above except the failing tests. I still need to:
|
added 3 commits
November 20, 2025 00:04
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>
Adding the initdir to PYTHONPATH allows users to "import" the "module" function in Python scripts. Signed-off-by: Byron Boulton <bboulton@ara.com>
a6b1156 to
9ad195b
Compare
xdelaruelle
requested changes
Nov 21, 2025
Collaborator
xdelaruelle
left a comment
There was a problem hiding this comment.
Please see my comments for the few changes to apply.
added 4 commits
November 21, 2025 19:18
Signed-off-by: Byron Boulton <bboulton@ara.com>
Signed-off-by: Byron Boulton <bboulton@ara.com>
Signed-off-by: Byron Boulton <bboulton@ara.com>
Signed-off-by: Byron Boulton <bboulton@ara.com>
Author
|
I pushed up some fixes. I want to rebase/squash them, but I need to sign off for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.