Skip to content

Commit 3678a82

Browse files
authored
Make "module-info shell" Tcl test compatible with Lmod<=8.7.55 (#682)
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.
1 parent 4bf959f commit 3678a82

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
1414
The versions coincide with releases on pip. Only major versions will be released as tags on Github.
1515

1616
## [0.0.x](https://github.com/singularityhub/singularity-hpc/tree/main) (0.0.x)
17+
- Fix `module-info shell` Tcl test for Lmod<=8.7.55 (0.1.30)
1718
- Allow import of LooseVersion from packaging (bug) (0.1.29)
1819
- use quay.io api to list tags since does not conform to oci (0.1.28)
1920
- filter out vex and sbom tags (0.1.27)

shpc/main/modules/templates/docker.tcl

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ set inspectCmd "{{ command }} \${PODMAN_OPTS} inspect ${containerPath}"
8686
{% if wrapper_scripts %}prepend-path PATH ${wrapperDir}/bin{% endif %}
8787

8888
# "aliases" to module commands
89-
{% if aliases %}if { [ module-info shell bash ] } {
89+
{% if aliases %}if { [ module-info shell ] eq {bash} } {
9090
if { [ module-info mode load ] } {
9191
{% 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 %}
9292
{% endfor %}
@@ -106,14 +106,14 @@ set-alias {|module_name|}-container "echo ${containerPath}"
106106
set-alias {|module_name|}-shell "${shellCmd}"
107107

108108
# A customizable exec function
109-
if { [ module-info shell bash ] } {
109+
if { [ module-info shell ] eq {bash} } {
110110
set-alias {|module_name|}-exec "${execCmd} --entrypoint \"\" ${containerPath} \"\$@\""
111111
} else {
112112
set-alias {|module_name|}-exec "${execCmd} --entrypoint \"\" ${containerPath}"
113113
}
114114

115115
# Always provide a container run
116-
if { [ module-info shell bash ] } {
116+
if { [ module-info shell ] eq {bash} } {
117117
set-alias {|module_name|}-run "${runCmd} \"\$@\""
118118
} else {
119119
set-alias {|module_name|}-run "${runCmd}"

shpc/main/modules/templates/singularity.tcl

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ set inspectCmd "singularity \${SINGULARITY_OPTS} inspect \${SINGULARITY_COMMAND_
9292
{% if wrapper_scripts %}prepend-path PATH ${wrapperDir}/bin{% endif %}
9393

9494
# "aliases" to module commands
95-
{% if aliases %}if { [ module-info shell bash ] } {
95+
{% if aliases %}if { [ module-info shell ] eq {bash} } {
9696
if { [ module-info mode load ] } {
9797
{% 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 %}
9898
{% endfor %}
@@ -111,14 +111,14 @@ set-alias {|module_name|}-shell "${shellCmd}"
111111
set-alias {|module_name|}-container "echo ${containerPath}"
112112

113113

114-
if { [ module-info shell bash ] } {
114+
if { [ module-info shell ] eq {bash} } {
115115
set-alias {|module_name|}-exec "${execCmd} ${containerPath} \"\$@\""
116116
} else {
117117
set-alias {|module_name|}-exec "${execCmd} ${containerPath}"
118118
}
119119

120120
# Always provide a container run
121-
if { [ module-info shell bash ] } {
121+
if { [ module-info shell ] eq {bash} } {
122122
set-alias {|module_name|}-run "${runCmd} \"\$@\""
123123
} else {
124124
set-alias {|module_name|}-run "${runCmd}"

shpc/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__copyright__ = "Copyright 2021-2025, Vanessa Sochat"
33
__license__ = "MPL 2.0"
44

5-
__version__ = "0.1.29"
5+
__version__ = "0.1.30"
66
AUTHOR = "Vanessa Sochat"
77
88
NAME = "singularity-hpc"

0 commit comments

Comments
 (0)