diff --git a/snakemake/deployment/singularity.py b/snakemake/deployment/singularity.py index 3cf319272..7c23f124a 100644 --- a/snakemake/deployment/singularity.py +++ b/snakemake/deployment/singularity.py @@ -113,6 +113,7 @@ def shellcmd( envvars=None, shell_executable=None, container_workdir=None, + is_python_script=False, ): """Execute shell command inside singularity container given optional args and environment variables to be passed.""" @@ -131,8 +132,9 @@ def shellcmd( # because we cannot be sure where it is located in the container. shell_executable = os.path.split(shell_executable)[-1] - # mount host snakemake module into container - args += " --bind {}:{}".format(SNAKEMAKE_SEARCHPATH, SNAKEMAKE_MOUNTPOINT) + if is_python_script: + # mount host snakemake module into container + args += " --bind {}:{}".format(SNAKEMAKE_SEARCHPATH, SNAKEMAKE_MOUNTPOINT) if container_workdir: args += " --pwd {}".format(container_workdir) diff --git a/snakemake/script.py b/snakemake/script.py index 36362315d..bb5d7af33 100644 --- a/snakemake/script.py +++ b/snakemake/script.py @@ -579,7 +579,9 @@ def execute_script(self, fname, edit=False): # bash is configured as executable on Windows py_exec = py_exec.replace("\\", "/") # use the same Python as the running process or the one from the environment - self._execute_cmd("{py_exec} {fname:q}", py_exec=py_exec, fname=fname) + self._execute_cmd( + "{py_exec} {fname:q}", py_exec=py_exec, fname=fname, is_python_script=True + ) class RScript(ScriptBase): diff --git a/snakemake/shell.py b/snakemake/shell.py index 601688e7e..2c9f543dc 100644 --- a/snakemake/shell.py +++ b/snakemake/shell.py @@ -184,6 +184,7 @@ def __new__( envvars=None, shell_executable=cls._process_args["executable"], container_workdir=shadow_dir, + is_python_script=context.get("is_python_script", False), ) logger.info("Activating singularity image {}".format(container_img)) if conda_env: