Skip to content

Commit df5fe23

Browse files
committed
move tests
1 parent 58c86d5 commit df5fe23

File tree

3 files changed

+155
-452
lines changed

3 files changed

+155
-452
lines changed

python/private/pypi/parse_requirements.bzl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ def parse_requirements(
148148

149149
options = {}
150150
requirements = {}
151-
for plat, file in requirements_by_platform.items():
151+
for file, plats in requirements_by_platform.items():
152+
if logger:
153+
logger.debug(lambda: "Using {} for {}".format(file, plats))
152154
contents = ctx.read(file)
153155

154156
# Parse the requirements file directly in starlark to get the information
@@ -181,10 +183,9 @@ def parse_requirements(
181183
tokenized_options.append(p)
182184

183185
pip_args = tokenized_options + extra_pip_args
184-
if logger:
185-
logger.debug(lambda: "Using {} for {}".format(file, plat))
186-
requirements[plat] = requirements_dict
187-
options[plat] = pip_args
186+
for plat in plats:
187+
requirements[plat] = requirements_dict
188+
options[plat] = pip_args
188189

189190
requirements_by_platform = {}
190191
reqs_with_env_markers = {}

python/private/pypi/requirements_files_by_platform.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,12 @@ def requirements_files_by_platform(
249249
return None, None
250250
requirements[p] = file
251251

252-
return requirements, len(platforms) > 0
252+
# Now return a dict that is similar to requirements_by_platform - where we
253+
# have labels/files as keys in the dict to minimize the number of times we
254+
# may parse the same file.
255+
256+
ret = {}
257+
for plat, file in requirements.items():
258+
ret.setdefault(file, []).append(plat)
259+
260+
return ret, len(platforms) > 0

0 commit comments

Comments
 (0)