openhpc / submissions

OpenHPC Component Submissions Project
8 stars 2 forks source link

environment-modules #48

Open xdelaruelle opened 2 years ago

xdelaruelle commented 2 years ago

Software Name

Environment Modules


Public URL

http://modules.sourceforge.net/


Technical Overview

The original module command. The Environment Modules project was live again in 2017 and a lot of new stuff has been added to the module command since them. Here is an overview of some of the new features added and a roadmap for the next releases. This slide deck also contains a short comparison with Lmod.

Version 5.1 has been released few days ago and starting this version Environment Modules can handle the Tcl modulefiles written for Lmod. So it now copes with the family, depends-on, module try-add commands used in OpenHPC modulefiles.

So it seems this is a good time to ask for the integration of Environment Modules in OpenHPC, as an alternative choice for users to the default solution (Lmod).


Latest stable version number

5.1.0


Open-source license type

GPLv2+


Relationship to component?

If other, please describe:


Build system

If other, please describe: configure script is a bash script, but it acts like an autotools-generated configure script.

A RPM spec file is available at https://github.com/cea-hpc/modules/blob/master/contrib/rpm/environment-modules.spec.in

Does the current build system support staged path installations? For example: make install DESTIR=/tmp/foo (or equivalent)


Does component run in user space or are administrative credentials required?


Does component require post-installation configuration.

If yes, please describe briefly: If you want to achieve an initial configuration of the user environment, with default modulepaths set and default module loaded, the /etc/environment-modules/initrc configuration file has to be changed. For instance, to reproduce a similar configuration than the one set in /etc/profile.d/lmod.{sh,csh}:

#%Module5.0
# ensure that module command is still defined in sub-shells
module config set_shell_startup 1

module use /opt/ohpc/pub/modulefiles
if {[module-info username root]} {
    module use /opt/ohpc/admin/modulefiles
}

# Load baseline OpenHPC environment
module try-add ohpc

If component is selected, are you willing and able to collaborate with OpenHPC maintainers during the integration process?


Does the component include test collateral (e.g. regression/verification tests) in the publicly shipped source?

If yes, please briefly describe the intent and location of the tests. Modules is shipped with:

All these tests rely on the DejaGnu framework


Does the component have additional software dependencies (beyond compilers/MPI) that are not part of standard Linux distributions?

If yes, please list the dependencies and associated licenses.


Does the component include online or installable documentation?

If available online, please provide URL. https://modules.readthedocs.io/en/stable/INSTALL.html


[Optional]: Would you like to receive additional review feedback by email?

- [x] yes - [ ] no
xdelaruelle commented 2 years ago

I have made some tests with a rebuilt EL8 OHPC container. I have built an environment-modules-ohpc package by applying the following patch on the RPM spec file shipped in the project's repository:

--- /path/to/modules/contrib/rpm/environment-modules.spec   2022-05-04 22:21:28.253456037 +0200
+++ environment-modules.spec    2022-05-04 19:36:20.000000000 +0200
@@ -1,7 +1,11 @@
 %global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)
 %global vimdatadir %{_datadir}/vim/vimfiles

-Name:           environment-modules
+%global ohpc_bootstrap 1
+%include %{_sourcedir}/OHPC_macros
+%define pname environment-modules
+
+Name:           %{pname}%{PROJ_DELIM}
 Version:        5.1.0
 Release:        1%{?dist}
 Summary:        Provides dynamic modification of a user's environment
@@ -46,6 +50,8 @@
 %endif
 Obsoletes:      modules-tcl <= 1.923
 Obsoletes:      environment-modules-compat <= 4.8.99
+Provides:       lmod%{PROJ_DELIM}
+Conflicts:      lmod%{PROJ_DELIM}

 %description
 The Environment Modules package provides for the dynamic modification of
@@ -85,7 +91,7 @@

 %configure --prefix=%{_datadir}/Modules \
            --libdir=%{_libdir} \
-           --etcdir=%{_sysconfdir}/%{name} \
+           --etcdir=%{_sysconfdir}/%{pname} \
            --bindir=%{_datadir}/Modules/bin \
            --libexecdir=%{_datadir}/Modules/libexec \
            --mandir=%{_mandir} \
@@ -95,9 +101,7 @@
            --with-zshcompletiondir=%{_datadir}/zsh/site-functions \
            --enable-multilib-support \
            --disable-doc-install \
-           --enable-modulespath \
            --with-python=%{pythonbin} \
-           --with-modulepath=%{_datadir}/Modules/modulefiles:%{_sysconfdir}/modulefiles:%{_datadir}/modulefiles \
            --with-quarantine-vars='LD_LIBRARY_PATH LD_PRELOAD'

 %if 0%{?fedora} >= 22 || 0%{?rhel} >= 7
@@ -142,7 +146,22 @@
 mv {doc/build/,}changes.txt

 # install the rpm config file
-install -Dpm 644 contrib/rpm/macros.%{name} %{buildroot}/%{macrosdir}/macros.%{name}
+install -Dpm 644 contrib/rpm/macros.%{pname} %{buildroot}/%{macrosdir}/macros.%{pname}
+
+# Customize startup configuration to suit
+%{__cat} << EOF > %{buildroot}/%{_sysconfdir}/%{pname}/initrc
+#%Module5.0
+# ensure that module command is still defined in sub-shells
+module config set_shell_startup 1
+
+module use %{OHPC_MODULES}
+if {[module-info username root]} {
+    module use %{OHPC_ADMIN}/modulefiles
+}
+
+# Load baseline OpenHPC environment
+module try-add ohpc
+EOF

 %check
@@ -206,16 +225,15 @@
 %{_datadir}/zsh/site-functions/_module
 %dir %{_datadir}/fish/vendor_completions.d
 %{_datadir}/fish/vendor_completions.d/module.fish
-%dir %{_sysconfdir}/%{name}
-%config(noreplace) %{_sysconfdir}/%{name}/initrc
-%config(noreplace) %{_sysconfdir}/%{name}/modulespath
-%config(noreplace) %{_sysconfdir}/%{name}/siteconfig.tcl
+%dir %{_sysconfdir}/%{pname}
+%config(noreplace) %{_sysconfdir}/%{pname}/initrc
+%config(noreplace) %{_sysconfdir}/%{pname}/siteconfig.tcl
 %{_datadir}/Modules/modulefiles
 %{_datadir}/modulefiles
 %{_mandir}/man1/ml.1.gz
 %{_mandir}/man1/module.1.gz
 %{_mandir}/man4/modulefile.4.gz
-%{macrosdir}/macros.%{name}
+%{macrosdir}/macros.%{pname}
 %{vimdatadir}/ftdetect/modulefile.vim
 %{vimdatadir}/ftplugin/modulefile.vim
 %{vimdatadir}/syntax/modulefile.vim

This RPM creates a default configuration in /etc/environment-modules/initrc similar to the one done in /etc/profile.d/lmod.{sh,csh} for Lmod.

As all OHPC RPMs requires lmod-ohpc, I have made the environment-modules-ohpc package providing lmod-ohpc. Works well, and does not require to change all spec files, but having every package requiring something like environment(module)-ohpc may be more appropriate in the long run.

Specific profile files like /etc/profile.d/a01_lmod_set_default.sh and /etc/profile.d/z01_lmod_load_default.sh are not needed for environment-modules: if modulepath and initial module to load are defined in /etc/environment-modules/initrc, they will be correctly set in login shell session and correctly refreshed in sub-shells.