Files
modules/init/python.in
Xavier Delaruelle 99668416d8 Introduce an installation process
Introduce an 'install' target in makefiles to provide an installation
process for modules-tcl.

Defines installation paths with Makefile variables in order to avoid
having a ./configure step. Install paths are set during the 'make' step
by passing 'prefix', 'libexecdir', 'mandir', etc arguments to the make
command. If no path definitions are passed to the 'make' command,
installation will be made in '/usr/local/modules-tcl' by default.

Installation paths provided (or set from the default value found in
Makefile) are saved at the 'make' step in a .makeinstallpath file. Then
at the 'make install' step, this .makeinstallpath file is read and make
knows where to install modules-tcl.

These paths definitions are also used to translate *.in init script to
their installed version.

modulecmd.tcl script is by default set to be installed in the libexec
directory to follow FHS specification (as this script is an executable
but not directly accessed by users).
2017-03-06 05:32:37 +01:00

24 lines
835 B
Plaintext

import os, re, subprocess
def module(command, *arguments):
exec(subprocess.Popen(['@TCLSH@', '@libexecdir@/modulecmd.tcl', 'python', command] + list(arguments), stdout=subprocess.PIPE).communicate()[0])
os.environ['MODULESHOME'] = '@prefix@'
if not 'MODULEPATH' in os.environ:
if os.access('@initdir@/.modulespath', os.R_OK):
pathlist = []
for fline in open('@initdir@/.modulespath', 'r').read().splitlines():
patharg = re.match('^\s*(.*?)[\s#].*$', fline)
if patharg and patharg.group(1):
pathlist.append(patharg.group(1))
os.environ['MODULEPATH'] = ':'.join(pathlist)
else:
os.environ['MODULEPATH'] = ''
if not 'LOADEDMODULES' in os.environ:
os.environ['LOADEDMODULES'] = ''
if os.access('@initdir@/modulerc', os.R_OK):
module('source', '@initdir@/modulerc')