File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,14 @@ def is_apptainer_1_or_newer() -> bool:
74
74
return False
75
75
return v [0 ][0 ] >= 1
76
76
77
+ def is_apptainer_1_1_or_newer () -> bool :
78
+ """
79
+ Check if apptainer singularity distribution is version 1.1 or higher.
80
+ """
81
+ v = get_version ()
82
+ if v [1 ] != "apptainer" :
83
+ return False
84
+ return v [0 ][0 ] >= 1 and v [0 ][1 ] >= 1
77
85
78
86
def is_version_2_6 () -> bool :
79
87
"""
@@ -118,6 +126,10 @@ def is_version_3_9_or_newer() -> bool:
118
126
v = get_version ()
119
127
return v [0 ][0 ] >= 4 or (v [0 ][0 ] == 3 and v [0 ][1 ] >= 9 )
120
128
129
+ def is_version_3_10_or_newer () -> bool :
130
+ """Detect if Singularity v3.10+ is available."""
131
+ v = get_version ()
132
+ return v [0 ][0 ] >= 4 or (v [0 ][0 ] == 3 and v [0 ][1 ] >= 10 )
121
133
122
134
def _normalize_image_id (string : str ) -> str :
123
135
return string .replace ("/" , "_" ) + ".img"
@@ -467,11 +479,17 @@ def create_runtime(
467
479
runtime = [
468
480
"singularity" ,
469
481
"--quiet" ,
470
- "run" ,
471
482
"--contain" ,
472
483
"--ipc" ,
473
484
"--cleanenv" ,
474
485
]
486
+
487
+ if is_apptainer_1_1_or_newer () or is_version_3_10_or_newer ():
488
+ runtime .append ("run" )
489
+ runtime .append ("--no-eval" )
490
+ else :
491
+ runtime .append ("exec" )
492
+
475
493
if singularity_supports_userns ():
476
494
runtime .append ("--userns" )
477
495
else :
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ def PWD(v: str, env: Env) -> bool:
149
149
if vminor == 5 :
150
150
sing_vars ["SINGULARITY_INIT" ] = "1"
151
151
elif vminor > 5 :
152
- sing_vars ["SINGULARITY_COMMAND" ] = "run "
152
+ sing_vars ["SINGULARITY_COMMAND" ] = "exec "
153
153
if vminor >= 7 :
154
154
if vminor > 9 :
155
155
sing_vars ["SINGULARITY_BIND" ] = ""
@@ -159,6 +159,8 @@ def BIND(v: str, env: Env) -> bool:
159
159
return v .startswith (tmp_prefix ) and v .endswith (":/tmp" )
160
160
161
161
sing_vars ["SINGULARITY_BIND" ] = BIND
162
+ if vminor >= 10 :
163
+ sing_vars ["SINGULARITY_COMMAND" ] = "run"
162
164
163
165
result .update (sing_vars )
164
166
You can’t perform that action at this time.
0 commit comments