PackagingDrafts/EnvironmentModules

Introduction
When one has multiple programs serving the same purpose (for instance SMTP servers such as sendmail, exim and postfix; or print servers such as lprng and cups), it is usual to wrap these using alternatives. Alternatives provides a clean way to have many types of software serving the same purpose installed at the same time and have the commands such as  and   point to the wanted versions.

However, when there are multiple variants that each serve the needs of some user and thus must be available simultaneously by users, the alternatives system simply isn't enough since it is system-wide. This has been reality on supercomputers and clusters for eons, and a solution has been developed: environment modules.

Using environment modules
To see what modules are available, run. To load a module run e.g.. To unload a module, run e.g..

The upstream documentation for the module command is available here.

Creating environment modules
To create an environment module, place a module file into. The directory  is to be used only for internal modules of environment-modules. Besides this, installing a module file into an arbitrary directory currently makes module unloading not working (see BZ#513583)

The module files are plain text with a tcl syntax, for instance an environment module for 32-bit OpenMPI :

prepend-path           PATH            /usr/lib/openmpi/bin prepend-path           LD_LIBRARY_PATH /usr/lib/openmpi/lib setenv                 MPI_BIN         /usr/lib/openmpi/bin setenv                 MPI_LIB         /usr/lib/openmpi/lib
 * 1) %Module 1.0
 * 2) OpenMPI module for use with 'environment-modules' package:
 * 1) OpenMPI module for use with 'environment-modules' package:

The module file begins with the magic cookie, where   is the version of the module file used. The current version is 1.0.

The above commands prepends the path with the bindir of the 32-bit OpenMPI (compiled with GCC) and adds the relevant library path. Then it sets five environment variables.

It is also possible to set  and   with the above manner, but in the case of MPI compilers it is not necessary since the compilers are invoked with the ,  ,   and   wrappers that already contain the necessary include and library paths. Also, in the case of development packages an override of  and/or   is not sane, as it may cause trouble in building RPMs as it overrides.

The upstream documentation for module files is available here.