Skip to content

Commit

Permalink
use a different deduplication strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
ricffb committed Dec 13, 2024
1 parent 2155689 commit e8f344c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions contrib/vcloud/podman_containerized_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 += [
Expand Down

0 comments on commit e8f344c

Please sign in to comment.