Skip to content

Commit 9f41d83

Browse files
feat: implement test for executable being contained in env
1 parent 957887b commit 9f41d83

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • src/snakemake_software_deployment_plugin_envmodules

src/snakemake_software_deployment_plugin_envmodules/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import shlex
22
from typing import Iterable
3+
from pathlib import Path
34
import subprocess as sp
45
from snakemake_interface_software_deployment_plugins import (
56
EnvBase,
@@ -54,6 +55,16 @@ def decorate_shellcmd(self, cmd: str) -> str:
5455
# help either...
5556
return f"module purge && module load {' '.join(shlex.quote(name) for name in self.spec.names)} && {cmd}"
5657

58+
def contains_executable(self, executable: str) -> bool:
59+
path = (
60+
self.run_cmd(
61+
self.decorate_shellcmd("echo $PATH"), capture_output=True, check=True
62+
)
63+
.stdout.decode()
64+
.split(":")[0]
65+
)
66+
return (Path(path) / executable).exists()
67+
5768
def record_hash(self, hash_object) -> None:
5869
# We just hash the names here as the best thing we can do for envmodules
5970
# for now. Ideally, the hash should change upon changes of what is deployed

0 commit comments

Comments
 (0)