From e8f344cfb8da4ccd2fb501c0f368686362f02bc2 Mon Sep 17 00:00:00 2001 From: Henrik Wachowitz Date: Fri, 13 Dec 2024 09:23:30 +0100 Subject: [PATCH] use a different deduplication strategy --- contrib/vcloud/podman_containerized_tool.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/contrib/vcloud/podman_containerized_tool.py b/contrib/vcloud/podman_containerized_tool.py index a164413af..ffebe9f56 100644 --- a/contrib/vcloud/podman_containerized_tool.py +++ b/contrib/vcloud/podman_containerized_tool.py @@ -39,11 +39,21 @@ def _init_container( # The modules are mounted at the exact same path in the container # because we do not yet know a solution to tell python to use # different paths for the modules in the container. - # We need to normalize and deduplicate the paths because Podman rejects duplicates. - import_paths = {Path(path).resolve() for path in sys.path if os.path.isdir(path)} + # We need to deduplicate the paths because Podman rejects duplicates. volumes = [] - for path in import_paths: - volumes += ["--volume", f"{path}:{path}:ro"] + seen_paths = set() + for path in sys.path: + path = Path(path) + resolved_path = path.resolve() + + # paths erlier in sys.path take precedence + if not resolved_path.is_dir() or resolved_path in seen_paths: + continue + + seen_paths.add(resolved_path) + + # we mount + volumes += ["--volume", f"{resolved_path}:{path}:ro"] # Mount the tool directory into the container at a known location volumes += [