From 05518d679a40faf19accc05c8a599d7d1a04c8ee Mon Sep 17 00:00:00 2001 From: Spencer Putt Date: Mon, 23 Dec 2024 14:40:49 -0500 Subject: [PATCH] Handle duplicate deps due to extras. --- private/reqs_repo.bzl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/private/reqs_repo.bzl b/private/reqs_repo.bzl index 8f00986..f004931 100644 --- a/private/reqs_repo.bzl +++ b/private/reqs_repo.bzl @@ -176,7 +176,6 @@ def parse_constraint(data, lockfile, wheel_dirs): """ url = None whl = None - via = None if "==" not in data[0]: fail("Unexpected line in constraints file: {}".format(data)) @@ -189,20 +188,22 @@ def parse_constraint(data, lockfile, wheel_dirs): else: sha256 = "" - via = [] + via = {} if len(data) > 2: for entry in data[2:-1]: text = entry.replace("# via", "#") pkg, _, _ = text.strip(" #").partition(" ") + # TODO: Support extras. + # Split off the extra. pkg, _, _ = pkg.partition("[") if not pkg: continue - # Skip any file paths. We only care to track packages + # Skip any file paths. We only care to track packages. if "/" in pkg or "\\" in pkg: continue - via.append(sanitize_package_name(pkg)) + via[sanitize_package_name(pkg)] = 1 whl = None if len(data) >= 4: @@ -238,7 +239,7 @@ def parse_constraint(data, lockfile, wheel_dirs): "sha256": sha256, "url": url, "version": version, - "via": sorted(via) if via != None else None, + "via": sorted(via) if via else None, "whl": whl, }