Files
modules/init/python.py.in
Xavier Delaruelle d918ee6d86 install: add --with-quarantine-vars
Add --with-quarantine-vars configure option to define quarantine
mechanism configuration at build time.

Value passed to the configure option will be used by Makefile to
initialize in the various initialization scripts the
MODULES_RUN_QUARANTINE variable and eventual MODULES_RUNENV_<VAR>.
2017-11-12 16:56:40 +01:00

33 lines
1.6 KiB
Python

import os, re, subprocess
# define modules runtine quarantine configuration
@setquarvars@os.environ['MODULES_RUN_QUARANTINE'] = '@RUN_QUARANTINE@'
@setquarvars@@os.environ['RUNENV_VAR'] = 'RUNENV_VAL'@
@notsetquarvars@#os.environ['MODULES_RUN_QUARANTINE'] = 'ENVVARNAME'
@notsetquarvars@
# setup quarantine if defined
_mlre = os.environ.copy()
if 'MODULES_RUN_QUARANTINE' in os.environ:
for _mlv in os.environ['MODULES_RUN_QUARANTINE'].split():
if re.match('^[A-Za-z_][A-Za-z0-9_]*$', _mlv):
if _mlv in os.environ:
_mlre[_mlv + '_modquar'] = os.environ[_mlv]
_mlrv = 'MODULES_RUNENV_' + _mlv
if _mlrv in os.environ:
_mlre[_mlv] = os.environ[_mlrv]
else:
_mlre[_mlv] = ''
# 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, env=_mlre).communicate()[0])
# clean temp variable used to setup quarantine
del _mlre
@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])