Skip to content

Commit

Permalink
Only --bind Snakemake when we're working with a Python script
Browse files Browse the repository at this point in the history
  • Loading branch information
frankier committed Oct 7, 2021
1 parent 0503a73 commit 2286cd7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions snakemake/deployment/singularity.py
Expand Up @@ -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."""
Expand All @@ -131,8 +132,12 @@ 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)
Expand Down
2 changes: 1 addition & 1 deletion snakemake/script.py
Expand Up @@ -579,7 +579,7 @@ 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):
Expand Down
1 change: 1 addition & 0 deletions snakemake/shell.py
Expand Up @@ -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:
Expand Down

0 comments on commit 2286cd7

Please sign in to comment.