Windows (since Windows 7) does support symlinks.
The command is mklink (I think it is a cmd.exe built-in).
Unfortunately, only administrators can make links (unless you change the security policy in windows).
Also - links in windows have a lot of issues (one is the copy and robocopy commands don't really handle them correctly).
Sourcing one file from the other is probably the best way to handle this (on Windows and Linux).
The module installation routine could determine if a python.py is there, and it should issue a warning if it is, then either install a default env_modules.py that sources python.py, or rename python.py
On 2025-11-10 2:49 PM, Xavier Delaruelle wrote:
> For Windows, you may just duplicate the file instead of the symlink.
> python.py init script will only be removed when releasing a new major
> version (v6). There will be documentation indicating the breaking
> changes. I think that will be sufficient. And for people currently
> using "python.py", I think they will not be happy to see a warning
> message.
>
> Xavier
>
> Le lun. 10 nov. 2025 à 20:08, Byron Boulton via Modules-interest
> <mod...@li...> a écrit :
>>
>> I'll definitely have to read through that file and get a better understanding of what it's doing. The Python code I'm having to write is to deal with the backwards compatibility of having the python.py file.
>>
>> Since environment modules supports Windows, but Windows doesn't support symlinks by default. So instead of a symlink my python.py grabs all variables/functions defined by the newly-renamed env_modules.py file and warns the users that using python.py is deprecated.
>>
>> Byron Boulton
>>
>> On Monday, November 10th, 2025 at 1:45 PM, Xavier Delaruelle <xav...@gm...> wrote:
>>
>>> Not sure there is a need to write Python code. I would suggest to
>>> update the cmdModuleAutoinit procedure to append-path the initdir to
>>> PYTHONPATH if configuration option is enabled:
>>>
>>> https://github.com/envmodules/modules/blob/2c416a8ebc95ee54e6653dbb47294563ad41721c/tcl/subcmd.tcl.in#L2032
>>>
>>> This way PYTHONPATH is adjusted when Modules initializes on all shells
>>> or langs supported.
>>>
>>> Best,
>>> Xavier
>>>
>>> Le lun. 10 nov. 2025 à 14:40, Byron Boulton via Modules-interest
>>> mod...@li... a écrit :
>>>
>>>> Is there an oldest version of Python we're supporting? For example, Python 3.6 or later? Note that Python 2.7 went end of life January 2020 (almost 6 years ago) and Python 3.6 went end of life December 2021 (almost 4 years ago). It would love to be able to use Pathlib which came in Python 3.4 and f-strings which came in Python 3.6.
>>>>
>>>> Byron Boulton
>>>>
>>>> On Sunday, November 9th, 2025 at 1:17 PM, Xavier Delaruelle xav...@gm... wrote:
>>>>
>>>>> Hello Byron,
>>>>>
>>>>> Thanks for your message. This is linked to
>>>>> https://github.com/envmodules/modules/issues/483.
>>>>>
>>>>> I am ok with the pull request you propose. Please take into account
>>>>> the following points:
>>>>> * I would prefer the init script to be renamed env_modules.py
>>>>> * At installation time a python.py symlink should be created not to
>>>>> break existing script relying on this file name
>>>>> * add a new configuration option that if activated adds the init dir
>>>>> path to the PYTHONPATH env variable during autoinit process
>>>>>
>>>>> Best,
>>>>> Xavier
>>>>>
>>>>> Le ven. 7 nov. 2025 à 21:02, Byron Boulton via Modules-interest
>>>>> mod...@li... a écrit :
>>>>>
>>>>>> To make things clearer for this email I'll use "Python-module" to refer to a Python script defining functions/classes that you `import` in Python code and "environment-module" to refer to a TCL environment module that you `module load`/`module unload`/etc.
>>>>>>
>>>>>> I was looking at how to use environment-modules within a Python script and found that the current documentation for Python (https://modules.readthedocs.io/en/latest/module.html#examples-of-initialization) has
>>>>>>
>>>>>> `import os exec(open("/usr/share/Modules/init/python.py").read(), globals()) module("load", "modulefile", "modulefile", "...")`
>>>>>>
>>>>>> A more Pythonic approach would be to `import` this `module` function somehow. Currently, you can do that with as follows
>>>>>>
>>>>>> `import sys sys.path.append("/usr/share/Modules/init") from python import module module("load", "modulefile", "moduelfile", "...")`
>>>>>>
>>>>>> The issues with this are that you have to modify the `sys.path` inside the script and since the Python-module `import`-ed is called "python". The name makes it look like `module` is a function from some core Python-module from the Python project.
>>>>>>
>>>>>> I'm proposing to write a pull request to
>>>>>> 1. rename the Python initialization file to something like `env_module_python.py` (this is what lmod named theirs by the way) and
>>>>>> 2. to have the shell initialization scripts add the folder of initilization scripts to the PYTHONPATH environment variable. These changes would change Python initialization to
>>>>>>
>>>>>> `from env_module_python import module module("load", "modulefile", "moduelfile", "...")`
>>>>>>
>>>>>> which cleans up the way the Python script imports the `module` function and communicates more clearly that it comes from a 3rd-party Python-module related to environment modules.
>>>>>>
>>>>>> Byron Boulton
>>>>>>
>>>>>> _______________________________________________
>>>>>> Modules-interest mailing list
>>>>>> Mod...@li...
>>>>>> https://lists.sourceforge.net/lists/listinfo/modules-interest
>>>>>
>>>>> _______________________________________________
>>>>> Modules-interest mailing list
>>>>> Mod...@li...
>>>>> https://lists.sourceforge.net/lists/listinfo/modules-interest
>>>>
>>>> _______________________________________________
>>>> Modules-interest mailing list
>>>> Mod...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/modules-interest
>>>
>>>
>>>
>>> _______________________________________________
>>> Modules-interest mailing list
>>> Mod...@li...
>>> https://lists.sourceforge.net/lists/listinfo/modules-interest
>>
>>
>> _______________________________________________
>> Modules-interest mailing list
>> Mod...@li...
>> https://lists.sourceforge.net/lists/listinfo/modules-interest
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
>
--
--------------------------------------------------------
The views and opinions expressed above are strictly
those of the author(s). The content of this message has
not been reviewed nor approved by any entity whatsoever.
--------------------------------------------------------
Paul FM Info: http://paulfm.com/~paulfm/
--------------------------------------------------------
|