@@ -75,6 +75,14 @@ def is_apptainer_1_or_newer() -> bool:
75
75
return v [0 ][0 ] >= 1
76
76
77
77
78
+ def is_apptainer_1_1_or_newer () -> bool :
79
+ """Check if apptainer singularity distribution is version 1.1 or higher."""
80
+ v = get_version ()
81
+ if v [1 ] != "apptainer" :
82
+ return False
83
+ return v [0 ][0 ] >= 2 or (v [0 ][0 ] >= 1 and v [0 ][1 ] >= 1 )
84
+
85
+
78
86
def is_version_2_6 () -> bool :
79
87
"""
80
88
Check if this singularity version is exactly version 2.6.
@@ -119,6 +127,12 @@ def is_version_3_9_or_newer() -> bool:
119
127
return v [0 ][0 ] >= 4 or (v [0 ][0 ] == 3 and v [0 ][1 ] >= 9 )
120
128
121
129
130
+ def is_version_3_10_or_newer () -> bool :
131
+ """Detect if Singularity v3.10+ is available."""
132
+ v = get_version ()
133
+ return v [0 ][0 ] >= 4 or (v [0 ][0 ] == 3 and v [0 ][1 ] >= 10 )
134
+
135
+
122
136
def _normalize_image_id (string : str ) -> str :
123
137
return string .replace ("/" , "_" ) + ".img"
124
138
@@ -464,14 +478,18 @@ def create_runtime(
464
478
) -> tuple [list [str ], Optional [str ]]:
465
479
"""Return the Singularity runtime list of commands and options."""
466
480
any_path_okay = self .builder .get_requirement ("DockerRequirement" )[1 ] or False
481
+
467
482
runtime = [
468
483
"singularity" ,
469
484
"--quiet" ,
470
- "exec" ,
485
+ "run" if is_apptainer_1_1_or_newer () or is_version_3_10_or_newer () else " exec" ,
471
486
"--contain" ,
472
487
"--ipc" ,
473
488
"--cleanenv" ,
474
489
]
490
+ if is_apptainer_1_1_or_newer () or is_version_3_10_or_newer ():
491
+ runtime .append ("--no-eval" )
492
+
475
493
if singularity_supports_userns ():
476
494
runtime .append ("--userns" )
477
495
else :
0 commit comments