Files
modules/init/python.py.in
Xavier Delaruelle 519d08e98d init: shell scripts now rely on autoinit command
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.
2017-10-23 22:35:27 +02:00

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])