mirror of
https://github.com/envmodules/modules.git
synced 2026-06-03 00:33:18 +08:00
Make use of autoinit module command to initialize module command and its initial surrounding environment (default value for MODULESHOME, MODULEPATH, LOADEDMODULES and parse of init/.modulespath). Then if compatibility version is currently activated redefined the module command to point to the compat binary. But the compat version will benefit from the surrounding environment initialization made by autoinit. With this change, activated compatibility version will also get its environment initialized by the init/modulerc file whereas before this change only the main version was affected by this setup file.
12 lines
797 B
Python
12 lines
797 B
Python
import os, re, subprocess
|
|
|
|
# define module command and surrounding initial environment (default value
|
|
# for MODULESHOME, MODULEPATH, LOADEDMODULES and parse of init/.modulespath)
|
|
exec(subprocess.Popen(['@TCLSH@', '@libexecdir@/modulecmd.tcl', 'python', 'autoinit'], stdout=subprocess.PIPE).communicate()[0])
|
|
@compatversion@
|
|
@compatversion@# redefine module command if compat version has been activated
|
|
@compatversion@if 'MODULES_USE_COMPAT_VERSION' in os.environ and os.environ['MODULES_USE_COMPAT_VERSION'] == '1':
|
|
@compatversion@ # set module command in accordance with active version
|
|
@compatversion@ def module(command, *arguments):
|
|
@compatversion@ exec(subprocess.Popen(['@libexecdir@/modulecmd-compat', 'python', command] + list(arguments), stdout=subprocess.PIPE).communicate()[0])
|