From 813f85cb00ef0078c94903e42fea35c806fc7302 Mon Sep 17 00:00:00 2001 From: Tanguy Lallemand Date: Mon, 28 Mar 2022 10:39:40 +0200 Subject: [PATCH 1/3] fix singularity logging messages causing conda fail --- snakemake/deployment/conda.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/snakemake/deployment/conda.py b/snakemake/deployment/conda.py index 473ac2b23..d7bb8870e 100644 --- a/snakemake/deployment/conda.py +++ b/snakemake/deployment/conda.py @@ -635,8 +635,7 @@ def _check(self): version.splitlines(), ) ) - - version = version.split()[1] + version = re.findall('\d+.\d+.\d+', version)[0] if StrictVersion(version) < StrictVersion("4.2"): raise CreateCondaEnvironmentException( "Conda must be version 4.2 or later, found version {}.".format( From f075589d1fedb3aa5ac4a6a8ef77b8a0f92e0806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20K=C3=B6ster?= Date: Mon, 28 Mar 2022 15:46:18 +0200 Subject: [PATCH 2/3] fix: only use STDOUT for conda version (conda prints version to STDOUT since at least 5 years now). --- snakemake/deployment/conda.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/snakemake/deployment/conda.py b/snakemake/deployment/conda.py index d7bb8870e..7d5ab4e35 100644 --- a/snakemake/deployment/conda.py +++ b/snakemake/deployment/conda.py @@ -624,18 +624,15 @@ def _check(self): try: version = shell.check_output( self._get_cmd("conda --version"), - stderr=subprocess.STDOUT, universal_newlines=True, ) - if self.container_img: - version = "\n".join( - filter( - lambda line: not line.startswith("WARNING:") - and not line.startswith("ERROR:"), - version.splitlines(), - ) + version_matches = re.findall("\d+.\d+.\d+", version) + if len(version_matches) != 1: + raise WorkflowError( + f"Unable to determine conda version. 'conda --version' returned {version}" ) - version = re.findall('\d+.\d+.\d+', version)[0] + else: + version = version_matches[0] if StrictVersion(version) < StrictVersion("4.2"): raise CreateCondaEnvironmentException( "Conda must be version 4.2 or later, found version {}.".format( From 522089083cfae12d9ac23f1fe3de20f58ab0a4c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20K=C3=B6ster?= Date: Mon, 28 Mar 2022 15:53:49 +0200 Subject: [PATCH 3/3] handling stderr on error --- snakemake/deployment/conda.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snakemake/deployment/conda.py b/snakemake/deployment/conda.py index 7d5ab4e35..d409e6952 100644 --- a/snakemake/deployment/conda.py +++ b/snakemake/deployment/conda.py @@ -624,6 +624,7 @@ def _check(self): try: version = shell.check_output( self._get_cmd("conda --version"), + stderr=subprocess.PIPE, universal_newlines=True, ) version_matches = re.findall("\d+.\d+.\d+", version) @@ -641,7 +642,7 @@ def _check(self): ) except subprocess.CalledProcessError as e: raise CreateCondaEnvironmentException( - "Unable to check conda version:\n" + e.output.decode() + "Unable to check conda version:\n" + e.stderr.decode() ) def bin_path(self):