From 6e2ecd26e48eb64fa04c9c38dde591857e03c722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20K=C3=B6ster?= Date: Tue, 11 Jan 2022 18:11:11 +0100 Subject: [PATCH] fix: fix source cache handling for remote source files retrieved via github() or gitlab() tags. (#1322) * fix: fix source cache handling for remote source files retrieved via github() or gitlab() tags. * fix: convert to url separators in windows case. --- snakemake/sourcecache.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/snakemake/sourcecache.py b/snakemake/sourcecache.py index 3d7a5bf1f..2566ea7d5 100644 --- a/snakemake/sourcecache.py +++ b/snakemake/sourcecache.py @@ -13,7 +13,13 @@ from abc import ABC, abstractmethod -from snakemake.common import is_local_file, get_appdirs, parse_uri, smart_join +from snakemake.common import ( + ON_WINDOWS, + is_local_file, + get_appdirs, + parse_uri, + smart_join, +) from snakemake.exceptions import WorkflowError, SourceFileError from snakemake.io import git_content, split_git_path from snakemake.logging import logger @@ -202,6 +208,10 @@ def get_basedir(self): def join(self, path): path = os.path.normpath("{}/{}".format(self.path, path)) + if ON_WINDOWS: + # convert back to URL separators + # (win specific separators are introduced by normpath above) + path = path.replace("\\", "/") return self.__class__( repo=self.repo, path=path, @@ -237,7 +247,7 @@ def get_path_or_uri(self): def infer_source_file(path_or_uri, basedir: SourceFile = None): if isinstance(path_or_uri, SourceFile): - if basedir is None: + if basedir is None or isinstance(path_or_uri, HostingProviderFile): return path_or_uri else: path_or_uri = path_or_uri.get_path_or_uri()