Skip to content

Commit fa04ed5

Browse files
committed
attempt to make tests pass
1 parent 16e0bc6 commit fa04ed5

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

Diff for: python/private/pypi/parse_requirements.bzl

+12-6
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,22 @@ def parse_requirements(
215215
logger = logger,
216216
)
217217

218+
target_platforms = env_marker_target_platforms.get(r.requirement_line, r.target_platforms)
219+
218220
if sdist:
219221
sha = sdist.sha256
220222
if sha not in sdists_by_sha:
221223
sdists_by_sha[sha] = struct(
224+
distribution = r.distribution,
225+
srcs = r.srcs,
226+
extra_pip_args = r.extra_pip_args,
222227
sdist = sdist,
223228
platforms = [],
224229
)
225-
sdists_by_sha[sha].platforms.extend(r.target_platforms)
226-
227-
target_platforms = env_marker_target_platforms.get(r.requirement_line, r.target_platforms)
230+
sdists_by_sha[sha].platforms.extend(target_platforms)
231+
232+
if len(whls) == 0:
233+
continue
228234

229235
ret_requirements.append(
230236
struct(
@@ -241,10 +247,10 @@ def parse_requirements(
241247
for sha, sdist_info in sdists_by_sha.items():
242248
ret_requirements.append(
243249
struct(
244-
distribution = r.distribution,
245-
srcs = r.srcs,
250+
distribution = sdist_info.distribution,
251+
srcs = sdist_info.srcs,
246252
target_platforms = sorted(sdist_info.platforms),
247-
extra_pip_args = r.extra_pip_args,
253+
extra_pip_args = sdist_info.extra_pip_args,
248254
whls = [],
249255
sdist = sdist_info.sdist,
250256
is_exposed = is_exposed,

Diff for: tests/pypi/parse_requirements/parse_requirements_tests.bzl

+5-2
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ def _test_sdist_different_hashes(env):
679679
requirement = "foo==0.0.1",
680680
requirement_line = "foo==0.0.1 --hash=sha256:deadbaaf --hash=sha256:cafebabe",
681681
shas = ["cafebabe", "deadbaaf"],
682+
url = "",
682683
version = "0.0.1",
683684
),
684685
target_platforms = ["cp315_linux_x86_64"],
@@ -701,6 +702,7 @@ def _test_sdist_different_hashes(env):
701702
requirement = "foo==0.0.1",
702703
requirement_line = "foo==0.0.1 --hash=sha256:deadbeef --hash=sha256:cafebabe",
703704
shas = ["cafebabe", "deadbeef"],
705+
url = "",
704706
version = "0.0.1",
705707
),
706708
target_platforms = ["cp315_windows_x86_64"],
@@ -726,8 +728,9 @@ def _test_sdist_different_hashes(env):
726728
srcs = struct(
727729
marker = "",
728730
requirement = "foo==0.0.1",
729-
requirement_line = "foo==0.0.1 --hash=sha256:deadbeef --hash=sha256:cafebabe",
730-
shas = ["cafebabe", "deadbeef"],
731+
requirement_line = "foo==0.0.1 --hash=sha256:deadbaaf --hash=sha256:cafebabe",
732+
shas = ["cafebabe", "deadbaaf"],
733+
url = "",
731734
version = "0.0.1",
732735
),
733736
target_platforms = ["cp315_linux_x86_64", "cp315_windows_x86_64"],

0 commit comments

Comments
 (0)