Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ dev_pip = use_extension(
parallel_download = False,
python_version = python_version,
requirements_lock = "//docs:requirements.txt",
# Ensure that we are setting up the following platforms
target_platforms = [
"{os}_{arch}",
"{os}_{arch}_freethreaded",
],
)
for python_version in [
"3.9",
Expand Down
2 changes: 2 additions & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ sphinx_build_binary(
config_settings = {
labels.BOOTSTRAP_IMPL: "script",
labels.VENVS_SITE_PACKAGES: "yes",
labels.PY_FREETHREADED: "yes",
labels.PYTHON_VERSION: "3.14",
},
target_compatible_with = _TARGET_COMPATIBLE_WITH,
deps = [
Expand Down
2 changes: 1 addition & 1 deletion python/private/pypi/extension.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ EXPERIMENTAL: this may be removed without notice.
""",
),
"target_platforms": attr.string_list(
default = ["{os}_{arch}"],
default = [],
doc = """\
The list of platforms for which we would evaluate the requirements files. If you need to be able to
only evaluate for a particular platform (e.g. "linux_x86_64"), then put it in here.
Expand Down
7 changes: 4 additions & 3 deletions python/private/pypi/hub_builder.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ def _pip_parse(self, module_ctx, pip_attr):
module_ctx,
python_version = full_python_version,
config = self._config,
# FIXME @aignas 2025-12-06: should we have this behaviour?
# TODO @aignas 2025-12-06: use target_platforms always even when the get_index_urls is set.
target_platforms = [] if default_cross_setup else pip_attr.target_platforms,
# TODO @aignas 2025-12-09: flip or part to default to 'os_arch' after
# VERSION_NEXT_FEATURE is released and set the default of the `target_platforms` attribute
# to `{os}_{arch}`.
target_platforms = pip_attr.target_platforms or ([] if default_cross_setup else ["{os}_{arch}"]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the logic is correct, this expression is a bit dense and can be hard to parse at a glance. For improved readability and maintainability, consider extracting this logic into a local variable before the _platforms call. This would make the logic for determining the target platforms more explicit.

For example:

default_target_platforms = [] if default_cross_setup else [\"{os}_{arch}\"]
final_target_platforms = pip_attr.target_platforms or default_target_platforms

Then you can pass final_target_platforms to the function call.

)
_add_group_map(self, pip_attr.experimental_requirement_cycles)
_add_extra_aliases(self, pip_attr.extra_hub_aliases)
Expand Down
2 changes: 2 additions & 0 deletions python/private/pypi/requirements_files_by_platform.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def requirements_files_by_platform(

input_platforms = platforms
default_platforms = [_platform(p, python_version) for p in platforms]
if logger:
logger.debug(lambda: "Input platforms: {}".format(input_platforms))

if platforms_from_args:
lock_files = [
Expand Down
8 changes: 5 additions & 3 deletions tests/pypi/extension/extension_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ load(":pip_parse.bzl", _parse = "pip_parse")

_tests = []

def _mock_mctx(*modules, environ = {}, read = None):
def _mock_mctx(*modules, os_name = "unittest", arch_name = "exotic", environ = {}, read = None):
return struct(
os = struct(
environ = environ,
name = "unittest",
arch = "exotic",
name = os_name,
arch = arch_name,
),
read = read or (lambda _: """\
simple==0.0.1 \
Expand Down Expand Up @@ -148,6 +148,8 @@ def _test_simple(env):
),
],
),
os_name = "linux",
arch_name = "x86_64",
),
available_interpreters = {
"python_3_15_host": "unit_test_interpreter_target",
Expand Down
Loading