Skip to content

Commit 36a5b01

Browse files
committed
wip
1 parent b258eb9 commit 36a5b01

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

python/private/pypi/extension.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def _create_whl_repos(
7171
whl_overrides,
7272
available_interpreters = INTERPRETER_LABELS,
7373
minor_mapping = MINOR_MAPPING,
74+
evaluate_markers = evaluate_markers_py,
7475
get_index_urls = None):
7576
"""create all of the whl repositories
7677
@@ -85,6 +86,7 @@ def _create_whl_repos(
8586
used during the `repository_rule` and must be always compatible with the host.
8687
minor_mapping: {type}`dict[str, str]` The dictionary needed to resolve the full
8788
python version used to parse package METADATA files.
89+
evaluate_markers: the function used to evaluate the markers.
8890
8991
Returns a {type}`struct` with the following attributes:
9092
whl_map: {type}`dict[str, list[struct]]` the output is keyed by the
@@ -186,7 +188,7 @@ def _create_whl_repos(
186188
# instances to perform this manipulation. This function should be executed
187189
# only once by the underlying code to minimize the overhead needed to
188190
# spin up a Python interpreter.
189-
evaluate_markers = lambda module_ctx, requirements: evaluate_markers_py(
191+
evaluate_markers = lambda module_ctx, requirements: evaluate_markers(
190192
module_ctx,
191193
requirements = requirements,
192194
python_interpreter = pip_attr.python_interpreter,

tests/pypi/extension/extension_tests.bzl

+25-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def _mock_mctx(*modules, environ = {}, read = None):
2626
return struct(
2727
os = struct(
2828
environ = environ,
29-
path = str,
3029
name = "unittest",
3130
arch = "exotic",
3231
),
@@ -275,6 +274,14 @@ torch==2.4.1 ; platform_machine != 'x86_64' \
275274
"python_3_15_host": "unit_test_interpreter_target",
276275
},
277276
minor_mapping = {"3.15": "3.15.19"},
277+
evaluate_markers = lambda _, requirements, **__: {
278+
key: [
279+
platform
280+
for platform in platforms
281+
if ("x86_64" in platform and "platform_machine ==" in key) or ("x86_64" not in platform and "platform_machine !=" in key)
282+
]
283+
for key, platforms in requirements.items()
284+
},
278285
)
279286

280287
pypi.exposed_packages().contains_exactly({"pypi": ["torch"]})
@@ -399,6 +406,15 @@ torch==2.4.1+cpu ; platform_machine == 'x86_64' \
399406
},
400407
minor_mapping = {"3.12": "3.12.19"},
401408
simpleapi_download = mocksimpleapi_download,
409+
evaluate_markers = lambda _, requirements, **__: {
410+
# todo once 2692 is merged, this is going to be easier to test.
411+
key: [
412+
platform
413+
for platform in platforms
414+
if ("x86_64" in platform and "platform_machine ==" in key) or ("x86_64" not in platform and "platform_machine !=" in key)
415+
]
416+
for key, platforms in requirements.items()
417+
},
402418
)
403419

404420
pypi.exposed_packages().contains_exactly({"pypi": ["torch"]})
@@ -858,6 +874,14 @@ optimum[onnxruntime-gpu]==1.17.1 ; sys_platform == 'linux'
858874
"python_3_15_host": "unit_test_interpreter_target",
859875
},
860876
minor_mapping = {"3.15": "3.15.19"},
877+
evaluate_markers = lambda _, requirements, **__: {
878+
key: [
879+
platform
880+
for platform in platforms
881+
if ("darwin" in key and "osx" in platform) or ("linux" in key and "linux" in platform)
882+
]
883+
for key, platforms in requirements.items()
884+
},
861885
)
862886

863887
pypi.exposed_packages().contains_exactly({"pypi": []})

0 commit comments

Comments
 (0)