From 758c8e2db2dd2c95a0872809b7aef7bbee38615a Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 28 Jul 2026 12:21:44 -0700 Subject: [PATCH 1/6] agents: add merge-pr skill for shepherding pull request merges (#3969) Add a standalone `merge-pr` skill that orchestrates pull request merges and merge queue monitoring. When invoked, the skill deploys a background `Merge PR Shepherd` subagent that uses `monitor-ci-results` to watch checks and analyze failure logs, automatically retries transient network flakes via `retry_buildkite_jobs.py`, and re-enqueues the pull request if it is ever ejected from the merge queue. --- .agents/skills/merge-pr/SKILL.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .agents/skills/merge-pr/SKILL.md diff --git a/.agents/skills/merge-pr/SKILL.md b/.agents/skills/merge-pr/SKILL.md new file mode 100644 index 0000000000..73086759ed --- /dev/null +++ b/.agents/skills/merge-pr/SKILL.md @@ -0,0 +1,14 @@ +--- +name: merge-pr +description: Merge a pull request into main, monitoring the merge queue, retrying CI flakes, and re-enqueuing if necessary +--- + +When the user asks to merge a pull request (e.g., "merge PR ", "merge this PR", or monitor its merge): + +1. **Enqueue for Merge**: Run `gh pr merge --auto --squash` to enable auto-merge or add the pull request to the merge queue. +2. **Invoke a Background Shepherd**: Launch a background subagent with the role `Merge PR Shepherd` to continuously watch the PR until it merges. +3. **Leverage Existing CI Skills**: + - Have the subagent use the **`monitor-ci-results`** skill to watch for CI check failures and generate analysis reports. + - Have the subagent use the **`buildkite-retry-job`** skill (`retry_buildkite_jobs.py `) to automatically retry any transient network flakes (e.g., HTTP 504 gateway timeouts, downloader errors). +4. **Queue Shepherding**: Periodically check `gh pr view --json state,autoMergeRequest`. While `state` is `"OPEN"`, ensure auto-merge is enabled / queued by running `gh pr merge --auto --squash`. If `autoMergeRequest` is null (e.g., ejected from the merge queue due to a CI flake in the temporary queue branch), re-enqueue it for merge by running `gh pr merge --auto --squash` once checks are retried or green. +5. **Completion Notification**: Once `state` becomes `"MERGED"`, send a high-priority message back to the parent conversation. From 7868f5d2f92b5d82bc999b3583f64e673b8a407f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jul 2026 14:16:51 -0700 Subject: [PATCH 2/6] build(deps): bump actions/upload-artifact from 4 to 7 (#3964) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 7.
Release notes

Sourced from actions/upload-artifact's releases.

v7.0.0

v7 What's new

Direct Uploads

Adds support for uploading single files directly (unzipped). Callers can set the new archive parameter to false to skip zipping the file during upload. Right now, we only support single files. The action will fail if the glob passed resolves to multiple files. The name parameter is also ignored with this setting. Instead, the name of the artifact will be the name of the uploaded file.

ESM

To support new versions of the @actions/* packages, we've upgraded the package to ESM.

What's Changed

New Contributors

Full Changelog: https://github.com/actions/upload-artifact/compare/v6...v7.0.0

v6.0.0

v6 - What's new

[!IMPORTANT] actions/upload-artifact@v6 now runs on Node.js 24 (runs.using: node24) and requires a minimum Actions Runner version of 2.327.1. If you are using self-hosted runners, ensure they are updated before upgrading.

Node.js 24

This release updates the runtime to Node.js 24. v5 had preliminary support for Node.js 24, however this action was by default still running on Node.js 20. Now this action by default will run on Node.js 24.

What's Changed

Full Changelog: https://github.com/actions/upload-artifact/compare/v5.0.0...v6.0.0

v5.0.0

What's Changed

BREAKING CHANGE: this update supports Node v24.x. This is not a breaking change per-se but we're treating it as such.

... (truncated)

Commits
  • 043fb46 Merge pull request #797 from actions/yacaovsnc/update-dependency
  • 634250c Include changes in typespec/ts-http-runtime 0.3.5
  • e454baa Readme: bump all the example versions to v7 (#796)
  • 74fad66 Update the readme with direct upload details (#795)
  • bbbca2d Support direct file uploads (#764)
  • 589182c Upgrade the module to ESM and bump dependencies (#762)
  • 47309c9 Merge pull request #754 from actions/Link-/add-proxy-integration-tests
  • 02a8460 Add proxy integration test
  • b7c566a Merge pull request #745 from actions/upload-artifact-v6-release
  • e516bc8 docs: correct description of Node.js 24 support in README
  • Additional commits viewable in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/upload-artifact&package-manager=github_actions&previous-version=4&new-version=7)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/automated_pr_review.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automated_pr_review.yaml b/.github/workflows/automated_pr_review.yaml index 179b1dcd4b..dbfffa9083 100644 --- a/.github/workflows/automated_pr_review.yaml +++ b/.github/workflows/automated_pr_review.yaml @@ -62,7 +62,7 @@ jobs: # Upload extracted diff as artifact to pass to Job 2 safely as text data. - name: Upload Diff Artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: pr_diff path: pr_diff.txt From 17e85173b956b0ddddb2671be283ad03c7425c40 Mon Sep 17 00:00:00 2001 From: Richard Sartor Date: Fri, 17 Jul 2026 21:47:16 +0000 Subject: [PATCH 3/6] Remove hasattr check. --- python/private/cc/py_extension_rule.bzl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/private/cc/py_extension_rule.bzl b/python/private/cc/py_extension_rule.bzl index e38f9288c3..967e6f0b82 100644 --- a/python/private/cc/py_extension_rule.bzl +++ b/python/private/cc/py_extension_rule.bzl @@ -140,8 +140,7 @@ def _get_platform(ctx): """ py_toolchain = ctx.toolchains[PY_CC_TOOLCHAIN_TYPE] py_cc_toolchain = py_toolchain.py_cc_toolchain - if hasattr(py_cc_toolchain, "platform_tag") and py_cc_toolchain.platform_tag: - return py_cc_toolchain.platform_tag + return py_cc_toolchain.platform_tag fail( "ERROR: Unable to resolve platform_tag from Python C++ toolchain for {self}. " + From 09313c4eec078f962d4c832ff40485ddf43f4c60 Mon Sep 17 00:00:00 2001 From: Richard Sartor Date: Tue, 21 Jul 2026 03:46:04 +0000 Subject: [PATCH 4/6] Replace 'os' and 'cpu' with PEP508 equivalents. --- python/private/py_cc_toolchain_info.bzl | 10 +++++ python/private/py_cc_toolchain_macro.bzl | 17 +++---- python/private/py_cc_toolchain_rule.bzl | 44 +++++++++++-------- .../py_cc_toolchain/py_cc_toolchain_tests.bzl | 30 +++++++++++++ .../support/py_cc_toolchain_info_subject.bzl | 21 +++++++++ 5 files changed, 91 insertions(+), 31 deletions(-) diff --git a/python/private/py_cc_toolchain_info.bzl b/python/private/py_cc_toolchain_info.bzl index 5ab9bb61f3..5de671fc9e 100644 --- a/python/private/py_cc_toolchain_info.bzl +++ b/python/private/py_cc_toolchain_info.bzl @@ -96,6 +96,11 @@ If available, information about C libraries, struct with fields: considered private and should be forward along as-is (this better allows e.g. `:current_py_cc_headers` to act as the underlying headers target it represents). +""", + "platform_machine": """ +:type: str + +The PEP 508 `platform_machine` marker value for the target architecture, e.g. 'x86_64', 'aarch64'. """, "platform_tag": """\ :type: str | None @@ -106,6 +111,11 @@ The PEP 3149 / PEP 425 platform tag for extension modules, e.g. 'x86_64-linux-gn :type: str The Python Major.Minor version. +""", + "sys_platform": """ +:type: str + +The PEP 508 `sys_platform` marker value for the target OS, e.g. 'linux', 'darwin', 'win32'. """, }, ) diff --git a/python/private/py_cc_toolchain_macro.bzl b/python/private/py_cc_toolchain_macro.bzl index 19a277b94b..bb08e21f74 100644 --- a/python/private/py_cc_toolchain_macro.bzl +++ b/python/private/py_cc_toolchain_macro.bzl @@ -14,6 +14,7 @@ """Fronting macro for the py_cc_toolchain rule.""" +load("//python/private/pypi:pep508_env.bzl", "platform_machine_select_map", "sys_platform_select_map") load(":py_cc_toolchain_rule.bzl", _py_cc_toolchain = "py_cc_toolchain") load(":util.bzl", "add_tag") @@ -31,18 +32,10 @@ def py_cc_toolchain(**kwargs): # This tag is added to easily identify usages through other macros. add_tag(kwargs, "@rules_python//python:py_cc_toolchain") - if "os" not in kwargs: - kwargs["os"] = select({ - "@platforms//os:macos": "macos", - "@platforms//os:windows": "windows", - "//conditions:default": "linux", - }) - if "cpu" not in kwargs: - kwargs["cpu"] = select({ - "@platforms//cpu:aarch64": "aarch64", - "@platforms//cpu:x86_32": "x86_32", - "//conditions:default": "x86_64", - }) + if "sys_platform" not in kwargs: + kwargs["sys_platform"] = select(sys_platform_select_map) + if "platform_machine" not in kwargs: + kwargs["platform_machine"] = select(platform_machine_select_map) if "libc" not in kwargs: kwargs["libc"] = select({ Label("//python/config_settings:_is_py_linux_libc_musl"): "musl", diff --git a/python/private/py_cc_toolchain_rule.bzl b/python/private/py_cc_toolchain_rule.bzl index b047974b6a..0c8a54bebe 100644 --- a/python/private/py_cc_toolchain_rule.bzl +++ b/python/private/py_cc_toolchain_rule.bzl @@ -25,8 +25,8 @@ load(":flags.bzl", "FreeThreadedFlag") load(":py_cc_toolchain_info.bzl", "PyCcToolchainInfo") load(":sentinel_impl.bzl", "SentinelInfo") -def _get_platform_tag(os, cpu, libc): - """Derives the PEP 3149 platform tag string based on target OS, CPU, and libc. +def _get_platform_tag(sys_platform, platform_machine, libc): + """Derives the PEP 3149 platform tag string based on target PEP 508 sys_platform, platform_machine, and libc. Note that these are platform tags for C extension filenames, not PEP 425 tags for wheels. @@ -41,25 +41,25 @@ def _get_platform_tag(os, cpu, libc): - https://github.com/python/cpython/commit/3b8124884c3655b4cf2629d741b18c1a38181805 Args: - os: Target OS, e.g. "windows", "macos", "linux" - cpu: Target CPU architecture, e.g. "x86_64", "aarch64", "x86_32" + sys_platform: Target PEP 508 OS marker, e.g. "win32", "darwin", "linux" + platform_machine: Target PEP 508 CPU marker, e.g. "x86_64", "aarch64", "x86_32" libc: Target C library variant, e.g. "gnu", "musl" Returns: The platform tag, e.g. "x86_64-linux-gnu", "darwin", or "win_amd64" """ - if os == "windows": - if cpu == "x86_64": + if sys_platform == "win32": + if platform_machine in ("x86_64", "amd64"): return "win_amd64" - if cpu == "aarch64": + if platform_machine in ("aarch64", "arm64"): return "win_arm64" return "win32" - if os == "macos": + if sys_platform == "darwin": return "darwin" - cpu_val = cpu if cpu else "x86_64" + machine_val = platform_machine if platform_machine else "x86_64" libc_val = libc if libc else "gnu" - return "{}-linux-{}".format(cpu_val, libc_val) + return "{}-linux-{}".format(machine_val, libc_val) def _py_cc_toolchain_impl(ctx): if ctx.attr.libs: @@ -92,14 +92,13 @@ def _py_cc_toolchain_impl(ctx): abi_tag = "cpython-{}{}{}".format(version_parts[0], version_parts[1], abi_flags) platform_tag = _get_platform_tag( - os = ctx.attr.os, - cpu = ctx.attr.cpu, + sys_platform = ctx.attr.sys_platform, + platform_machine = ctx.attr.platform_machine, libc = ctx.attr.libc, ) py_cc_toolchain = PyCcToolchainInfo( abi_tag = abi_tag, - platform_tag = platform_tag, headers = struct( providers_map = { "CcInfo": ctx.attr.headers[CcInfo], @@ -108,7 +107,10 @@ def _py_cc_toolchain_impl(ctx): ), headers_abi3 = headers_abi3, libs = libs, + platform_machine = ctx.attr.platform_machine, + platform_tag = platform_tag, python_version = ctx.attr.python_version, + sys_platform = ctx.attr.sys_platform, ) extra_kwargs = {} if ctx.attr._visible_for_testing[BuildSettingInfo].value: @@ -125,10 +127,6 @@ py_cc_toolchain = rule( doc = "The ABI tag for extension modules, e.g. 'cpython-311'", default = "", ), - "cpu": attr.string( - doc = "Target CPU architecture, e.g. 'x86_64', 'aarch64', 'x86_32'", - default = "", - ), "headers": attr.label( doc = ("Target that provides the Python headers. Typically this " + "is a cc_library target."), @@ -158,14 +156,22 @@ attribute is available or not. "Typically this is a cc_library target of `.so` files."), providers = [CcInfo], ), - "os": attr.string( - doc = "Target OS, e.g. 'linux', 'macos', 'windows'", + "platform_machine": attr.string( + doc = """ +Target architecture as a PEP 508 `platform_machine` marker, e.g. 'x86_64', 'aarch64', 'x86_32'. +""", default = "", ), "python_version": attr.string( doc = "The Major.minor Python version, e.g. 3.11", mandatory = True, ), + "sys_platform": attr.string( + doc = """ +Target OS as a PEP 508 `sys_platform` marker, e.g. 'linux', 'darwin', 'win32'. +""", + default = "", + ), "_py_freethreaded_flag": attr.label( default = labels.PY_FREETHREADED, ), diff --git a/tests/cc/py_cc_toolchain/py_cc_toolchain_tests.bzl b/tests/cc/py_cc_toolchain/py_cc_toolchain_tests.bzl index 975f0d56b5..836af80c03 100644 --- a/tests/cc/py_cc_toolchain/py_cc_toolchain_tests.bzl +++ b/tests/cc/py_cc_toolchain/py_cc_toolchain_tests.bzl @@ -118,8 +118,38 @@ def _test_py_cc_toolchain_impl(env, target): matching.str_matches("/libpython3."), ) + # ===== Verify PEP 508 platform markers ===== + toolchain.sys_platform().equals("linux") + toolchain.platform_machine().equals("x86_64") + toolchain.platform_tag().equals("x86_64-linux-gnu") + _tests.append(_test_py_cc_toolchain) +def _test_custom_pep508_markers(name): + py_cc_toolchain( + name = name + "_subject", + headers = "//tests/support/cc_toolchains:py_headers", + platform_machine = "arm64", + python_version = "3.11", + sys_platform = "darwin", + ) + analysis_test( + name = name, + target = name + "_subject", + impl = _test_custom_pep508_markers_impl, + ) + +def _test_custom_pep508_markers_impl(env, target): + toolchain = PyCcToolchainInfoSubject.new( + target[platform_common.ToolchainInfo].py_cc_toolchain, + meta = env.expect.meta.derive(expr = "py_cc_toolchain_info"), + ) + toolchain.sys_platform().equals("darwin") + toolchain.platform_machine().equals("arm64") + toolchain.platform_tag().equals("darwin") + +_tests.append(_test_custom_pep508_markers) + def _test_libs_optional(name): py_cc_toolchain( name = name + "_subject", diff --git a/tests/support/py_cc_toolchain_info_subject.bzl b/tests/support/py_cc_toolchain_info_subject.bzl index 3820e04e90..1ddbc26ce4 100644 --- a/tests/support/py_cc_toolchain_info_subject.bzl +++ b/tests/support/py_cc_toolchain_info_subject.bzl @@ -21,7 +21,10 @@ def _py_cc_toolchain_info_subject_new(info, *, meta): headers = lambda *a, **k: _py_cc_toolchain_info_subject_headers(self, *a, **k), headers_abi3 = lambda *a, **k: _py_cc_toolchain_info_subject_headers_abi3(self, *a, **k), libs = lambda *a, **k: _py_cc_toolchain_info_subject_libs(self, *a, **k), + platform_machine = lambda *a, **k: _py_cc_toolchain_info_subject_platform_machine(self, *a, **k), + platform_tag = lambda *a, **k: _py_cc_toolchain_info_subject_platform_tag(self, *a, **k), python_version = lambda *a, **k: _py_cc_toolchain_info_subject_python_version(self, *a, **k), + sys_platform = lambda *a, **k: _py_cc_toolchain_info_subject_sys_platform(self, *a, **k), actual = info, ) self = struct(actual = info, meta = meta) @@ -54,12 +57,30 @@ def _py_cc_toolchain_info_subject_libs(self): ), ) +def _py_cc_toolchain_info_subject_platform_machine(self): + return subjects.str( + self.actual.platform_machine, + meta = self.meta.derive("platform_machine()"), + ) + +def _py_cc_toolchain_info_subject_platform_tag(self): + return subjects.str( + self.actual.platform_tag, + meta = self.meta.derive("platform_tag()"), + ) + def _py_cc_toolchain_info_subject_python_version(self): return subjects.str( self.actual.python_version, meta = self.meta.derive("python_version()"), ) +def _py_cc_toolchain_info_subject_sys_platform(self): + return subjects.str( + self.actual.sys_platform, + meta = self.meta.derive("sys_platform()"), + ) + # Disable this to aid doc generation # buildifier: disable=name-conventions PyCcToolchainInfoSubject = struct( From 3b6699bfd14372e9abf97d3d25b11078c042c251 Mon Sep 17 00:00:00 2001 From: Richard Sartor Date: Tue, 28 Jul 2026 23:11:26 +0000 Subject: [PATCH 5/6] Mark the new feature as experimental. --- python/cc/py_extension.bzl | 5 ++++- python/private/cc/py_extension_macro.bzl | 8 +++++++- python/private/cc/py_extension_rule.bzl | 11 ++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/python/cc/py_extension.bzl b/python/cc/py_extension.bzl index 72a9ce843c..53a1a73e38 100644 --- a/python/cc/py_extension.bzl +++ b/python/cc/py_extension.bzl @@ -1,4 +1,7 @@ -"""Public API for py_extension.""" +"""Public API for py_extension. + +EXPERIMENTAL: This feature is experimental and may be changed or removed without notice. +""" load( "//python/private/cc:py_extension_macro.bzl", diff --git a/python/private/cc/py_extension_macro.bzl b/python/private/cc/py_extension_macro.bzl index afb690e88a..f649eec810 100644 --- a/python/private/cc/py_extension_macro.bzl +++ b/python/private/cc/py_extension_macro.bzl @@ -1,4 +1,7 @@ -"""Macro for creating Python extensions.""" +"""Macro for creating Python extensions. + +EXPERIMENTAL: This feature is experimental and may be changed or removed without notice. +""" load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_cc//cc:cc_shared_library.bzl", "cc_shared_library") @@ -24,6 +27,9 @@ def py_extension( **kwargs): """Creates a Python extension module. + :::{include} /_includes/experimental_api.md + ::: + By default, extensions are created within their workspace package directory (e.g., `pkg/ext.so`) and imported using standard Python package paths (e.g., `from pkg import ext`). diff --git a/python/private/cc/py_extension_rule.bzl b/python/private/cc/py_extension_rule.bzl index 967e6f0b82..e62731851f 100644 --- a/python/private/cc/py_extension_rule.bzl +++ b/python/private/cc/py_extension_rule.bzl @@ -1,4 +1,7 @@ -"""Implementation of the _py_extension_wrapper rule.""" +"""Implementation of the _py_extension_wrapper rule. + +EXPERIMENTAL: This feature is experimental and may be changed or removed without notice. +""" load("@bazel_skylib//lib:dicts.bzl", "dicts") load("@rules_cc//cc/common:cc_shared_library_info.bzl", "CcSharedLibraryInfo") @@ -97,6 +100,12 @@ PY_EXTENSION_WRAPPER_ATTRS = dicts.add( def create_py_extension_wrapper_rule_builder(**kwargs): """Create a rule builder for the wrapper.""" builder = ruleb.Rule( + doc = """ +:::{include} /_includes/experimental_api.md +::: + +Internal wrapper rule for py_extension targets. +""", implementation = _py_extension_wrapper_impl, attrs = PY_EXTENSION_WRAPPER_ATTRS, provides = [PyInfo], From 523d4f3a155af2095db6c478fa38314fa16fdfc6 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Wed, 29 Jul 2026 03:31:01 +0000 Subject: [PATCH 6/6] Update py_extension & py_cc_toolchain docstrings and kwargs handling - Standardize experimental API docstring includes and wrap at 80 columns. - Document wrapper rule builder as private internal helper. - Link PEP 508 in PyCcToolchainInfo docstrings. - Handle explicit None in py_cc_toolchain macro kwargs. --- python/cc/py_extension.bzl | 3 ++- python/private/cc/py_extension_macro.bzl | 3 ++- python/private/cc/py_extension_rule.bzl | 22 +++++++++------------- python/private/py_cc_toolchain_info.bzl | 9 ++++++--- python/private/py_cc_toolchain_macro.bzl | 6 +++--- python/private/py_cc_toolchain_rule.bzl | 2 +- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/python/cc/py_extension.bzl b/python/cc/py_extension.bzl index 53a1a73e38..b7b4e2ea70 100644 --- a/python/cc/py_extension.bzl +++ b/python/cc/py_extension.bzl @@ -1,6 +1,7 @@ """Public API for py_extension. -EXPERIMENTAL: This feature is experimental and may be changed or removed without notice. +:::{include} /_includes/experimental_api.md +::: """ load( diff --git a/python/private/cc/py_extension_macro.bzl b/python/private/cc/py_extension_macro.bzl index b8b067e85b..810d5ad0e8 100644 --- a/python/private/cc/py_extension_macro.bzl +++ b/python/private/cc/py_extension_macro.bzl @@ -1,6 +1,7 @@ """Macro for creating Python extensions. -EXPERIMENTAL: This feature is experimental and may be changed or removed without notice. +:::{include} /_includes/experimental_api.md +::: """ load("@rules_cc//cc:cc_library.bzl", "cc_library") diff --git a/python/private/cc/py_extension_rule.bzl b/python/private/cc/py_extension_rule.bzl index e62731851f..3c8c10af5b 100644 --- a/python/private/cc/py_extension_rule.bzl +++ b/python/private/cc/py_extension_rule.bzl @@ -1,6 +1,7 @@ """Implementation of the _py_extension_wrapper rule. -EXPERIMENTAL: This feature is experimental and may be changed or removed without notice. +:::{include} /_includes/experimental_api.md +::: """ load("@bazel_skylib//lib:dicts.bzl", "dicts") @@ -98,14 +99,9 @@ PY_EXTENSION_WRAPPER_ATTRS = dicts.add( ) def create_py_extension_wrapper_rule_builder(**kwargs): - """Create a rule builder for the wrapper.""" + """Create a rule builder for the private internal wrapper rule.""" builder = ruleb.Rule( - doc = """ -:::{include} /_includes/experimental_api.md -::: - -Internal wrapper rule for py_extension targets. -""", + doc = "Private internal helper rule for py_extension targets.", implementation = _py_extension_wrapper_impl, attrs = PY_EXTENSION_WRAPPER_ATTRS, provides = [PyInfo], @@ -149,9 +145,9 @@ def _get_platform(ctx): """ py_toolchain = ctx.toolchains[PY_CC_TOOLCHAIN_TYPE] py_cc_toolchain = py_toolchain.py_cc_toolchain + if not py_cc_toolchain.platform_tag: + fail( + "ERROR: Unable to resolve platform_tag from Python C++ toolchain for {self}. " + + "Please ensure the active py_cc_toolchain provides a non-empty platform_tag.", + ) return py_cc_toolchain.platform_tag - - fail( - "ERROR: Unable to resolve platform_tag from Python C++ toolchain for {self}. " + - "Please ensure the active py_cc_toolchain provides a non-empty platform_tag.", - ) diff --git a/python/private/py_cc_toolchain_info.bzl b/python/private/py_cc_toolchain_info.bzl index 5de671fc9e..26ef2deaa7 100644 --- a/python/private/py_cc_toolchain_info.bzl +++ b/python/private/py_cc_toolchain_info.bzl @@ -100,12 +100,14 @@ If available, information about C libraries, struct with fields: "platform_machine": """ :type: str -The PEP 508 `platform_machine` marker value for the target architecture, e.g. 'x86_64', 'aarch64'. +The [PEP 508](https://peps.python.org/pep-0508/) `platform_machine` marker +value for the target architecture, e.g. 'x86_64', 'aarch64'. """, "platform_tag": """\ :type: str | None -The PEP 3149 / PEP 425 platform tag for extension modules, e.g. 'x86_64-linux-gnu', 'darwin', or 'win_amd64'. +The PEP 3149 / PEP 425 platform tag for extension modules, e.g. +'x86_64-linux-gnu', 'darwin', or 'win_amd64'. """, "python_version": """ :type: str @@ -115,7 +117,8 @@ The Python Major.Minor version. "sys_platform": """ :type: str -The PEP 508 `sys_platform` marker value for the target OS, e.g. 'linux', 'darwin', 'win32'. +The [PEP 508](https://peps.python.org/pep-0508/) `sys_platform` marker value +for the target OS, e.g. 'linux', 'darwin', 'win32'. """, }, ) diff --git a/python/private/py_cc_toolchain_macro.bzl b/python/private/py_cc_toolchain_macro.bzl index bb08e21f74..c04b4f3b4b 100644 --- a/python/private/py_cc_toolchain_macro.bzl +++ b/python/private/py_cc_toolchain_macro.bzl @@ -32,11 +32,11 @@ def py_cc_toolchain(**kwargs): # This tag is added to easily identify usages through other macros. add_tag(kwargs, "@rules_python//python:py_cc_toolchain") - if "sys_platform" not in kwargs: + if kwargs.get("sys_platform") == None: kwargs["sys_platform"] = select(sys_platform_select_map) - if "platform_machine" not in kwargs: + if kwargs.get("platform_machine") == None: kwargs["platform_machine"] = select(platform_machine_select_map) - if "libc" not in kwargs: + if kwargs.get("libc") == None: kwargs["libc"] = select({ Label("//python/config_settings:_is_py_linux_libc_musl"): "musl", "//conditions:default": "gnu", diff --git a/python/private/py_cc_toolchain_rule.bzl b/python/private/py_cc_toolchain_rule.bzl index 0c8a54bebe..eefc52d0ca 100644 --- a/python/private/py_cc_toolchain_rule.bzl +++ b/python/private/py_cc_toolchain_rule.bzl @@ -26,7 +26,7 @@ load(":py_cc_toolchain_info.bzl", "PyCcToolchainInfo") load(":sentinel_impl.bzl", "SentinelInfo") def _get_platform_tag(sys_platform, platform_machine, libc): - """Derives the PEP 3149 platform tag string based on target PEP 508 sys_platform, platform_machine, and libc. + """Derives the PEP 3149 platform tag string. Note that these are platform tags for C extension filenames, not PEP 425 tags for wheels.