File tree 9 files changed +80
-12
lines changed
9 files changed +80
-12
lines changed Original file line number Diff line number Diff line change @@ -33,9 +33,18 @@ force:
33
33
conda_arch : ' Linux-x86_64'
34
34
max_num_cpus : 4
35
35
# No logic currently to refer to other variables here
36
- # So either implement that, throw them to $TMPDIR
37
- #
36
+ # So either implement that, throw them to $TMPDIR
38
37
workdir : $PWD
38
+ # What executable name or path to use for singularity
39
+ # For fully dynamic behavior
40
+ # You can just set singularity or apptainer here.
41
+ # Keep in mind that this could break installations
42
+ # if e.g the user installs singularity via conda
43
+ # when user namespaces are not enabled
44
+ # Environment variables can be used here
45
+ # but they will be expanded during build,
46
+ # not during runtime
47
+ singularity_executable_path : " singularity"
39
48
40
49
# Value will override any user set value
41
50
Original file line number Diff line number Diff line change @@ -41,6 +41,16 @@ force:
41
41
# So either implement that, throw them to $TMPDIR
42
42
#
43
43
workdir : $PWD
44
+ # What executable name or path to use for singularity
45
+ # For fully dynamic behavior
46
+ # You can just set singularity or apptainer here.
47
+ # Keep in mind that this could break installations
48
+ # if e.g the user installs singularity via conda
49
+ # when user namespaces are not enabled
50
+ # Environment variables can be used here
51
+ # but they will be expanded during build,
52
+ # not during runtime
53
+ singularity_executable_path : " /usr/bin/singularity"
44
54
45
55
# Value will override any user set value
46
56
Original file line number Diff line number Diff line change @@ -39,6 +39,16 @@ force:
39
39
# So either implement that, throw them to $TMPDIR
40
40
#
41
41
workdir : $PWD
42
+ # What executable name or path to use for singularity
43
+ # For fully dynamic behavior
44
+ # You can just set singularity or apptainer here.
45
+ # Keep in mind that this could break installations
46
+ # if e.g the user installs singularity via conda
47
+ # when user namespaces are not enabled
48
+ # Environment variables can be used here
49
+ # but they will be expanded during build,
50
+ # not during runtime
51
+ singularity_executable_path : " /usr/bin/singularity"
42
52
43
53
# Value will override any user set value
44
54
Original file line number Diff line number Diff line change @@ -40,6 +40,16 @@ force:
40
40
# So either implement that, throw them to $TMPDIR
41
41
#
42
42
workdir : $PWD
43
+ # What executable name or path to use for singularity
44
+ # For fully dynamic behavior
45
+ # You can just set singularity or apptainer here.
46
+ # Keep in mind that this could break installations
47
+ # if e.g the user installs singularity via conda
48
+ # when user namespaces are not enabled
49
+ # Environment variables can be used here
50
+ # but they will be expanded during build,
51
+ # not during runtime
52
+ singularity_executable_path : " /usr/bin/singularity"
43
53
44
54
# Value will override any user set value
45
55
Original file line number Diff line number Diff line change @@ -54,18 +54,18 @@ export install_root=$CW_INSTALLATION_PATH
54
54
55
55
56
56
if [[ " $CW_UPDATE_INSTALLATION " == " yes" ]]; then
57
- _CONTAINER_EXEC=" singularity --silent exec -B _deploy/$CW_SQFS_IMAGE :$CW_SOURCE_MOUNT_POINT :image-src=/ _deploy/$CW_CONTAINER_IMAGE "
57
+ _CONTAINER_EXEC=" $CW_SINGULARITY_EXECUTABLE_PATH --silent exec -B _deploy/$CW_SQFS_IMAGE :$CW_SOURCE_MOUNT_POINT :image-src=/ _deploy/$CW_CONTAINER_IMAGE "
58
58
export SINGULARITY_BIND=" $SINGULARITY_BIND ,$PWD /_inst_dir:$CW_INSTALLATION_PATH ,$_inst_path /_bin:$_inst_path /bin"
59
59
print_info " Copying installation to writable area, might take a while" 1
60
60
print_info " $( readlink -f $CW_INSTALLATION_PREFIX ) " 1
61
61
$_CONTAINER_EXEC cp -a $CW_SOURCE_MOUNT_POINT /. $CW_INSTALLATION_PATH || { print_err " Failed to copy some files, most likely incorrect file permissions inside the squashfs image" && false ; }
62
62
elif [[ " $CW_MODE " == " wrapdisk" ]]; then
63
63
export SINGULARITY_BIND=" $SINGULARITY_BIND ,$PWD /_inst_dir:$CW_INSTALLATION_PATH ,$CW_WRAP_SRC :$CW_SOURCE_MOUNT_POINT "
64
- _CONTAINER_EXEC=" singularity --silent exec _deploy/$CW_CONTAINER_IMAGE "
64
+ _CONTAINER_EXEC=" $CW_SINGULARITY_EXECUTABLE_PATH --silent exec _deploy/$CW_CONTAINER_IMAGE "
65
65
66
66
else
67
67
export SINGULARITY_BIND=" $SINGULARITY_BIND ,$PWD /_inst_dir:$CW_INSTALLATION_PATH "
68
- _CONTAINER_EXEC=" singularity --silent exec _deploy/$CW_CONTAINER_IMAGE "
68
+ _CONTAINER_EXEC=" $CW_SINGULARITY_EXECUTABLE_PATH --silent exec _deploy/$CW_CONTAINER_IMAGE "
69
69
fi
70
70
cp ./_sing_inst_script.sh _pre_install.sh _post_install.sh _inst_dir
71
71
print_info " Running installation script" 1
Original file line number Diff line number Diff line change 98
98
export _inst_path=$( realpath -s $PWD /$CW_INSTALLATION_PREFIX )
99
99
fi
100
100
101
+ if ! command -v $CW_SINGULARITY_EXECUTABLE_PATH & > /dev/null; then
102
+ { print_err " The command $CW_SINGULARITY_EXECUTABLE_PATH does not exists
103
+ Verify that the value for 'singularity_executable_path' in $CW_GLOBAL_YAML is correct" ; false ; }
104
+ fi
105
+
106
+ print_info " Validating the set singularity command $CW_SINGULARITY_EXECUTABLE_PATH " 2
107
+ num_res=$( $CW_SINGULARITY_EXECUTABLE_PATH --help | grep " build\|exec\|shell" 2> /dev/null | wc -l)
108
+ if [[ " $num_res " -lt 3 ]]; then
109
+ { print_err " $CW_SINGULARITY_EXECUTABLE_PATH does not seem to be a valid apptainer/singularity executable" ; false ; }
110
+ fi
111
+
112
+
113
+
101
114
$M_SCRIPT_DIR /../pre.sh || { print_err " Failed getting container image" ; false ; }
102
115
# Nothing to do if we are just wrapping a container
103
116
if [[ ! " $CW_MODE " == " wrapcont" ]]; then
Original file line number Diff line number Diff line change @@ -15,14 +15,14 @@ echo "#!/bin/bash" > _deploy/common.sh
15
15
16
16
17
17
if [[ " $CW_MODE " == " wrapcont" ]]; then
18
- _CONTAINER_EXEC=" /usr/bin/singularity --silent exec _deploy/$CW_CONTAINER_IMAGE "
19
- _RUN_CMD=" /usr/bin/singularity --silent exec \$ DIR/../\$ CONTAINER_IMAGE"
20
- _SHELL_CMD=" /usr/bin/singularity --silent shell \$ DIR/../\$ CONTAINER_IMAGE"
18
+ _CONTAINER_EXEC=" $CW_SINGULARITY_EXECUTABLE_PATH --silent exec _deploy/$CW_CONTAINER_IMAGE "
19
+ _RUN_CMD=" $CW_SINGULARITY_EXECUTABLE_PATH --silent exec \$ DIR/../\$ CONTAINER_IMAGE"
20
+ _SHELL_CMD=" $CW_SINGULARITY_EXECUTABLE_PATH --silent shell \$ DIR/../\$ CONTAINER_IMAGE"
21
21
else
22
- _CONTAINER_EXEC=" /usr/bin/singularity --silent exec -B _deploy/$CW_SQFS_IMAGE :$CW_INSTALLATION_PATH :image-src=/ _deploy/$CW_CONTAINER_IMAGE "
22
+ _CONTAINER_EXEC=" $CW_SINGULARITY_EXECUTABLE_PATH --silent exec -B _deploy/$CW_SQFS_IMAGE :$CW_INSTALLATION_PATH :image-src=/ _deploy/$CW_CONTAINER_IMAGE "
23
23
echo " SQFS_IMAGE=$CW_SQFS_IMAGE " >> _deploy/common.sh
24
- _RUN_CMD=" /usr/bin/singularity --silent exec \$ DIR/../\$ CONTAINER_IMAGE"
25
- _SHELL_CMD=" /usr/bin/singularity --silent shell \$ DIR/../\$ CONTAINER_IMAGE"
24
+ _RUN_CMD=" $CW_SINGULARITY_EXECUTABLE_PATH --silent exec \$ DIR/../\$ CONTAINER_IMAGE"
25
+ _SHELL_CMD=" $CW_SINGULARITY_EXECUTABLE_PATH --silent shell \$ DIR/../\$ CONTAINER_IMAGE"
26
26
fi
27
27
28
28
# Need to unset the path, otherwise we might be stuck in a nasty loop
Original file line number Diff line number Diff line change @@ -14,8 +14,11 @@ mkdir -p $CW_BUILD_TMPDIR/_deploy/
14
14
15
15
if [[ ! -e $CW_CONTAINER_SRC ]]; then
16
16
print_info " Fetching container $CW_CONTAINER_SRC " 1
17
- singularity --silent pull $CW_BUILD_TMPDIR /_deploy/$CW_CONTAINER_IMAGE $CW_CONTAINER_SRC || \
17
+ $CW_SINGULARITY_EXECUTABLE_PATH --silent pull $CW_BUILD_TMPDIR /_deploy/$CW_CONTAINER_IMAGE $CW_CONTAINER_SRC || \
18
18
{ print_err " Failed fetching container" ; exit 1 ; }
19
+ if [[ ! -e $CW_BUILD_TMPDIR /_deploy/$CW_CONTAINER_IMAGE ]]; then
20
+ { print_err " $CW_SINGULARITY_EXECUTABLE_PATH pull returned success, but no container was fetched" ; exit 1 ; }
21
+ fi
19
22
else
20
23
if [[ ${CW_SHARE_CONTAINER+defined} && ${CW_SHARE_CONTAINER} == " yes" ]]; then
21
24
print_info " Using container $CW_CONTAINER_SRC " 1
Original file line number Diff line number Diff line change @@ -32,6 +32,19 @@ rule ghelp:
32
32
"""
33
33
' > Snakefile
34
34
35
+ cat ../../default_config/config.yaml | sed " s@singularity_executable_path.*@singularity_executable_path: 'ThisIsNotACommand'@g" > my_config.yaml
36
+ export CW_GLOBAL_YAML=$( readlink -f my_config.yaml)
37
+ t_run " conda-containerize new --mamba env2.yml --prefix S | grep 'ThisIsNotACommand does not exists'" " Exit if configured singularity command does not exist"
38
+ cat ../../default_config/config.yaml | sed " s@singularity_executable_path.*@singularity_executable_path: 'my_sing_command'@g" > my_config.yaml
39
+ echo " #!/bin/bash" > my_sing_command
40
+ echo " exit 0" >> my_sing_command
41
+ chmod +x my_sing_command
42
+ export PATH=$PATH :$PWD
43
+ t_run " conda-containerize new --mamba env2.yml --prefix S | grep 'does not seem to be a valid apptainer/singularity executable'" " Exit if configured singularity command seems broken"
44
+ # Run the rest of the test with singularity found from path.
45
+ cat ../../default_config/config.yaml | sed " s@singularity_executable_path.*@singularity_executable_path: 'singularity'@g" > my_config.yaml
46
+
47
+
35
48
t_run " conda-containerize new --mamba env2.yml --prefix S" " mamba works"
36
49
t_run " conda-containerize new --mamba env.yml --prefix Gdal" " gdal installed"
37
50
export OPATH=$PATH
You can’t perform that action at this time.
0 commit comments