diff --git a/snk/cli/cli.py b/snk/cli/cli.py index fe27ef0..b201712 100644 --- a/snk/cli/cli.py +++ b/snk/cli/cli.py @@ -54,12 +54,8 @@ def __init__(self, workflow_dir_path: Path = None) -> None: self.version = self.workflow.commit self.options = build_dynamic_cli_options(self.snakemake_config, self.snk_config) self.snakefile = self._find_snakefile() - self.conda_prefix_dir = workflow_dir_path / ".conda" - if " " in str(workflow_dir_path): - # cannot have spaces! - self.singularity_prefix_dir = None - else: - self.singularity_prefix_dir = workflow_dir_path / ".singularity" + self.conda_prefix_dir = self.workflow.conda_prefix_dir + self.singularity_prefix_dir = self.workflow.singularity_prefix_dir self.name = self.workflow.name self.verbose = False if ( diff --git a/snk/main.py b/snk/main.py index 2c25ac5..625c6fb 100644 --- a/snk/main.py +++ b/snk/main.py @@ -192,7 +192,7 @@ def list( for workflow in workflows: if workflow.editable: print( - f'- {workflow.name} ([bold green]editable[/bold green]) -> "{workflow.path}"' + f'- {workflow.name} ([bold green]editable[/bold green]) -> "{workflow.path.resolve()}"' ) continue print(f"- {workflow.name} ([bold green]{workflow.version}[/bold green])") diff --git a/snk/nest.py b/snk/nest.py index 10d11a5..1ddfce6 100644 --- a/snk/nest.py +++ b/snk/nest.py @@ -428,7 +428,7 @@ def create_executable(self, workflow_path: Path, name: str) -> Path: from snk import create_cli if __name__ == "__main__": sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(create_cli("{workflow_path.resolve()}")) + sys.exit(create_cli("{workflow_path}")) """ ) diff --git a/snk/workflow.py b/snk/workflow.py index a8ea726..df2b485 100644 --- a/snk/workflow.py +++ b/snk/workflow.py @@ -35,6 +35,7 @@ def __init__(self, path: Path) -> None: self.repo = None self.name = self.path.name + @property def tag(self): """ @@ -43,7 +44,6 @@ def tag(self): str: The tag of the workflow, or None if no tag is found. """ try: - # TODO: default to commit tag = self.repo.git.describe(["--tags", "--exact-match"]) except Exception: tag = None @@ -91,6 +91,28 @@ def executable(self): if sys.platform.startswith("win"): name += ".exe" return workflow_bin_dir / name + + @property + def conda_prefix_dir(self): + """ + Gets the conda prefix directory of the workflow. + Returns: + Path: The path to the conda prefix directory. + """ + return Path(".snakemake") / "conda" if self.editable else self.path / ".conda" + + @property + def singularity_prefix_dir(self): + """ + Gets the singularity prefix directory of the workflow. + Returns: + Path: The path to the singularity prefix directory. + """ + if " " in str(self.path): + # sigh, snakemake singularity does not support spaces in the path + # https://github.com/snakemake/snakemake/blob/2ecb21ba04088b9e6850447760f713784cf8b775/snakemake/deployment/singularity.py#L130C1-L131C1 + return None + return Path(".snakemake") / "singularity" if self.editable else self.path / ".singularity" @property def editable(self):