Skip to content

Commit

Permalink
Make "module-info shell" Tcl test compatible with Lmod<=8.7.55
Browse files Browse the repository at this point in the history
Up to Lmod 8.7.55, the Tcl command "module-info shell" only returns the
current shell name and cannot test if a given string corresponds this
current shell.

A patch is now merged on Lmod, so newer version (8.7.56+) will cope with
the "module-info shell bash" syntax.

But in the mean time, I propose here to use a test Tcl syntax that will
be compatible with both Lmod and Environment Modules: "[module-info
shell] eq {bash}".

This change may only be of help for people willing to use the Tcl
modules produced by SHPC with the Lmod module tool.
  • Loading branch information
xdelaruelle committed Jan 11, 2025
1 parent 4bf959f commit e1a1395
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions shpc/main/modules/templates/docker.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ set inspectCmd "{{ command }} \${PODMAN_OPTS} inspect ${containerPath}"
{% if wrapper_scripts %}prepend-path PATH ${wrapperDir}/bin{% endif %}

# "aliases" to module commands
{% if aliases %}if { [ module-info shell bash ] } {
{% if aliases %}if { [ module-info shell ] eq {bash} ] } {
if { [ module-info mode load ] } {
{% for alias in aliases %}{% if alias.name not in wrapper_scripts %} puts stdout "function {{ alias.name }}() { ${execCmd} {% if alias.docker_options %} {{ alias.docker_options | replace("$", "\$") }} {% endif %} --entrypoint {{ alias.entrypoint | replace("$", "\$") }} ${containerPath} {{ alias.args | replace("$", "\$") }} \"\$@\"; }; export -f {{ alias.name }};"{% endif %}
{% endfor %}
Expand All @@ -106,14 +106,14 @@ set-alias {|module_name|}-container "echo ${containerPath}"
set-alias {|module_name|}-shell "${shellCmd}"

# A customizable exec function
if { [ module-info shell bash ] } {
if { [ module-info shell ] eq {bash} ] } {
set-alias {|module_name|}-exec "${execCmd} --entrypoint \"\" ${containerPath} \"\$@\""
} else {
set-alias {|module_name|}-exec "${execCmd} --entrypoint \"\" ${containerPath}"
}

# Always provide a container run
if { [ module-info shell bash ] } {
if { [ module-info shell ] eq {bash} ] } {
set-alias {|module_name|}-run "${runCmd} \"\$@\""
} else {
set-alias {|module_name|}-run "${runCmd}"
Expand Down
6 changes: 3 additions & 3 deletions shpc/main/modules/templates/singularity.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ set inspectCmd "singularity \${SINGULARITY_OPTS} inspect \${SINGULARITY_COMMAND_
{% if wrapper_scripts %}prepend-path PATH ${wrapperDir}/bin{% endif %}

# "aliases" to module commands
{% if aliases %}if { [ module-info shell bash ] } {
{% if aliases %}if { [ module-info shell ] eq {bash} ] } {
if { [ module-info mode load ] } {
{% for alias in aliases %} {% if alias.name not in wrapper_scripts %} puts stdout "function {{ alias.name }}() { ${execCmd} {% if alias.singularity_options %} {{ alias.singularity_options | replace("$", "\$") }} {% endif %} ${containerPath} {{ alias.command | replace("$", "\$") }} \"\$@\"; }; export -f {{ alias.name }};"{% endif %}
{% endfor %}
Expand All @@ -111,14 +111,14 @@ set-alias {|module_name|}-shell "${shellCmd}"
set-alias {|module_name|}-container "echo ${containerPath}"


if { [ module-info shell bash ] } {
if { [ module-info shell ] eq {bash} ] } {
set-alias {|module_name|}-exec "${execCmd} ${containerPath} \"\$@\""
} else {
set-alias {|module_name|}-exec "${execCmd} ${containerPath}"
}

# Always provide a container run
if { [ module-info shell bash ] } {
if { [ module-info shell ] eq {bash} ] } {
set-alias {|module_name|}-run "${runCmd} \"\$@\""
} else {
set-alias {|module_name|}-run "${runCmd}"
Expand Down
5 changes: 3 additions & 2 deletions shpc/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# set a default module system
# Currently lmod and tcl are supported. To request an additional system,
# please open an issue https://github.com/singularityhub/singularity-hpc
module_sys: lmod
module_sys: tcl

# config editor
config_editor: vim

# set a default container technology (singularity or podman)
container_tech: singularity
container_tech: podman

# Registry Recipes (order of GitHub providers or paths here is honored for search path))
# To reference a path in the $PWD of the shpc install use $root_dir (e.g., $root_dir/registry)
Expand Down Expand Up @@ -108,3 +108,4 @@ container_features:
# defaults to ~/.Xauthority if set to true and the container has x11: true
home: # one of null, or a single path or src:dest path.
# home: true in a container.yaml will use this path, if defines
updated_at: '2025-01-11T07:37:33Z'

0 comments on commit e1a1395

Please sign in to comment.