Skip to content

Commit b18cd54

Browse files
authored
Merge branch 'main' into feat/runfiles-compact-repo-manifest
2 parents 76e04d0 + fec87e4 commit b18cd54

29 files changed

+495
-111
lines changed

AGENTS.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ using a grandoise title.
1919
When tasks complete successfully, quote Monty Python, but work it naturally
2020
into the sentence, not verbatim.
2121

22+
When adding `{versionadded}` or `{versionchanged}` sections, add them add the
23+
end of the documentation text.
24+
25+
### Starlark style
26+
27+
For doc strings, using triple quoted strings when the doc string is more than
28+
three lines. Do not use a trailing backslack (`\`) for the opening triple-quote.
29+
2230
### bzl_library targets for bzl source files
2331

2432
* A `bzl_library` target should be defined for every `.bzl` file outside
@@ -78,7 +86,17 @@ When modifying documentation
7886
* Act as an expert in tech writing, Sphinx, MyST, and markdown.
7987
* Wrap lines at 80 columns
8088
* Use hyphens (`-`) in file names instead of underscores (`_`).
81-
89+
* In Sphinx MyST markup, outer directives must have more colons than inner
90+
directives. For example:
91+
```
92+
::::{outerdirective}
93+
outer text
94+
95+
:::{innertdirective}
96+
inner text
97+
:::
98+
::::
99+
```
82100

83101
Generated API references can be found by:
84102
* Running `bazel build //docs:docs` and inspecting the generated files

CHANGELOG.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ END_UNRELEASED_TEMPLATE
7979
length errors due to too long environment variables.
8080
* (bootstrap) {obj}`--bootstrap_impl=script` now supports the `-S` interpreter
8181
setting.
82-
* (pypi) We now use the Minimal Version Selection (MVS) algorithm to select
83-
the right wheel when there are multiple wheels for the target platform
84-
(e.g. `musllinux_1_1_x86_64` and `musllinux_1_2_x86_64`). If the user
85-
wants to set the minimum version for the selection algorithm, use the
86-
{attr}`pip.defaults.whl_platform_tags` attribute to configure that. If
87-
`musllinux_*_x86_64` is specified, we will chose the lowest available
88-
wheel version. Fixes [#3250](https://github.com/bazel-contrib/rules_python/issues/3250).
8982
* (venvs) {obj}`--vens_site_packages=yes` no longer errors when packages with
9083
overlapping files or directories are used together.
9184
([#3204](https://github.com/bazel-contrib/rules_python/issues/3204)).
@@ -105,7 +98,31 @@ END_UNRELEASED_TEMPLATE
10598
`WORKSPACE` files. See the
10699
{ref}`common-deps-with-multiple-pypi-versions` guide on using common
107100
dependencies with multiple PyPI versions` for an example.
101+
* (toolchains) Stable ABI headers support added. To use, depend on
102+
{obj}`//python/cc:current_py_cc_headers_abi3`. This allows Windows builds
103+
a way to depend on headers without the potentially Python unstable ABI
104+
objects from the regular {obj}`//python/cc:current_py_cc_headers` target
105+
being included.
106+
* Adds {obj}`//python/cc:current_py_cc_headers_abi3`,
107+
{obj}`py_cc_toolchain.headers_abi3`, and {obj}`PyCcToolchainInfo.headers_abi3`.
108+
* {obj}`//python:features.bzl%features.headers_abi3` can be used to
109+
feature-detect the presense of the above.
110+
111+
{#v1-6-3}
112+
## [1.6.3] - 2025-09-21
113+
114+
[1.6.3]: https://github.com/bazel-contrib/rules_python/releases/tag/1.6.3
115+
116+
{#v1-6-3-fixed}
117+
### Fixed
108118

119+
* (pypi) We now use the Minimal Version Selection (MVS) algorithm to select
120+
the right wheel when there are multiple wheels for the target platform
121+
(e.g. `musllinux_1_1_x86_64` and `musllinux_1_2_x86_64`). If the user
122+
wants to set the minimum version for the selection algorithm, use the
123+
{attr}`pip.defaults.whl_platform_tags` attribute to configure that. If
124+
`musllinux_*_x86_64` is specified, we will choose the lowest available
125+
wheel version. Fixes [#3250](https://github.com/bazel-contrib/rules_python/issues/3250).
109126

110127
{#v1-6-0}
111128
## [1.6.0] - 2025-08-23

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,4 @@ For detailed documentation, see <https://rules-python.readthedocs.io>
2525

2626
## Bzlmod support
2727

28-
- Status: Beta
29-
- Full Feature Parity: No
30-
3128
See [Bzlmod support](BZLMOD_SUPPORT.md) for more details.

docs/api/rules_python/python/cc/index.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:::
55
# //python/cc
66

7-
:::{bzl:target} current_py_cc_headers
7+
::::{bzl:target} current_py_cc_headers
88

99
A convenience target that provides the Python headers. It uses toolchain
1010
resolution to find the headers for the Python runtime matching the interpreter
@@ -14,7 +14,32 @@ that will be used. This basically forwards the underlying
1414
This target provides:
1515

1616
* `CcInfo`: The C++ information about the Python headers.
17+
18+
:::{seealso}
19+
20+
The {obj}`:current_py_cc_headers_abi3` target for explicitly using the
21+
stable ABI.
22+
:::
23+
24+
::::
25+
26+
::::{bzl:target} current_py_cc_headers_abi3
27+
28+
A convenience target that provides the Python ABI3 headers (stable ABI headers).
29+
It uses toolchain resolution to find the headers for the Python runtime matching
30+
the interpreter that will be used. This basically forwards the underlying
31+
`cc_library(name="python_headers_abi3")` target defined in the `@python_X_Y`
32+
repo.
33+
34+
This target provides:
35+
36+
* `CcInfo`: The C++ information about the Python ABI3 headers.
37+
38+
:::{versionadded} VERSION_NEXT_FEATURE
39+
The {obj}`features.headers_abi3` attribute can be used to detect if this target
40+
is available or not.
1741
:::
42+
::::
1843

1944
:::{bzl:target} current_py_cc_libs
2045

docs/howto/python-headers.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ files. This guide shows how to get the necessary include paths from the Python
88
[toolchain](toolchains).
99

1010
The recommended way to get the headers is to depend on the
11-
`@rules_python//python/cc:current_py_cc_headers` target. This is a helper
12-
target that uses toolchain resolution to find the correct headers for the
13-
target platform.
11+
{obj}`@rules_python//python/cc:current_py_cc_headers` or
12+
{obj}`@rules_python//python/cc:current_py_cc_headers_abi3`
13+
targets. These are convenience targets that use toolchain resolution to find
14+
the correct headers for the target platform.
1415

1516
## Using the headers
1617

@@ -27,4 +28,27 @@ cc_library(
2728
```
2829

2930
This setup ensures that your C extension code can find and use the Python
30-
headers during compilation.
31+
headers during compilation.
32+
33+
:::{note}
34+
The `:current_py_cc_headers` target provides all the Python headers. This _may_
35+
include ABI-specific information.
36+
:::
37+
38+
## Using the stable ABI headers
39+
40+
If you're building for the [Python stable ABI](https://docs.python.org/3/c-api/stable.html),
41+
then depend on {obj}`@rules_python//python/cc:current_py_cc_headers_abi3`. This
42+
target contains only objects relevant to the Python stable ABI. Remember to
43+
define
44+
[`Py_LIMITED_API`](https://docs.python.org/3/c-api/stable.html#c.Py_LIMITED_API)
45+
when building such extensions.
46+
47+
```bazel
48+
# BUILD.bazel
49+
cc_library(
50+
name = "my_stable_abi_extension",
51+
srcs = ["my_stable_abi_extension.c"],
52+
deps = ["@rules_python//python/cc:current_py_cc_headers_abi3"],
53+
)
54+
```

docs/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ dependencies = [
1212
"readthedocs-sphinx-ext",
1313
"absl-py",
1414
"typing-extensions",
15-
"sphinx-reredirects"
15+
"sphinx-reredirects",
16+
"pefile"
1617
]

docs/requirements.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ colorama==0.4.6 ; sys_platform == 'win32' \
111111
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
112112
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
113113
# via sphinx
114-
docutils==0.22 \
115-
--hash=sha256:4ed966a0e96a0477d852f7af31bdcb3adc049fbb35ccba358c2ea8a03287615e \
116-
--hash=sha256:ba9d57750e92331ebe7c08a1bbf7a7f8143b86c476acd51528b042216a6aad0f
114+
docutils==0.21.2 \
115+
--hash=sha256:3a6b18732edf182daa3cd12775bbb338cf5691468f91eeeb109deff6ebfa986f \
116+
--hash=sha256:dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2
117117
# via
118118
# myst-parser
119119
# sphinx
@@ -232,6 +232,10 @@ packaging==25.0 \
232232
# via
233233
# readthedocs-sphinx-ext
234234
# sphinx
235+
pefile==2024.8.26 \
236+
--hash=sha256:3ff6c5d8b43e8c37bb6e6dd5085658d658a7a0bdcd20b6a07b1fcfc1c4e9d632 \
237+
--hash=sha256:76f8b485dcd3b1bb8166f1128d395fa3d87af26360c2358fb75b80019b957c6f
238+
# via rules-python-docs (docs/pyproject.toml)
235239
pygments==2.19.2 \
236240
--hash=sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887 \
237241
--hash=sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b

python/cc/BUILD.bazel

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
44
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED")
5-
load("//python/private:current_py_cc_headers.bzl", "current_py_cc_headers")
5+
load("//python/private:current_py_cc_headers.bzl", "current_py_cc_headers", "current_py_cc_headers_abi3")
66
load("//python/private:current_py_cc_libs.bzl", "current_py_cc_libs")
77

88
package(
@@ -20,6 +20,17 @@ current_py_cc_headers(
2020
visibility = ["//visibility:public"],
2121
)
2222

23+
# This target provides the C ABI3 headers for whatever the current toolchain is
24+
# for the consuming rule. It basically acts like a cc_library by forwarding
25+
# on the providers for the underlying cc_library that the toolchain is using.
26+
current_py_cc_headers_abi3(
27+
name = "current_py_cc_headers_abi3",
28+
# Building this directly will fail unless a py cc toolchain is registered,
29+
# and it's only under bzlmod that one is registered by default.
30+
tags = [] if BZLMOD_ENABLED else ["manual"],
31+
visibility = ["//visibility:public"],
32+
)
33+
2334
# This target provides the C libraries for whatever the current toolchain is for
2435
# the consuming rule. It basically acts like a cc_library by forwarding on the
2536
# providers for the underlying cc_library that the toolchain is using.

python/features.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ _VERSION_PRIVATE = "$Format:%(describe:tags=true)$"
2222
def _features_typedef():
2323
"""Information about features rules_python has implemented.
2424
25+
::::{field} headers_abi3
26+
:type: bool
27+
28+
True if the {obj}`@rules_python//python/cc:current_py_cc_headers_abi3`
29+
target is available.
30+
31+
:::{versionadded} VERSION_NEXT_FEATURE
32+
:::
33+
::::
34+
2535
::::{field} precompile
2636
:type: bool
2737
@@ -60,6 +70,7 @@ def _features_typedef():
6070
features = struct(
6171
TYPEDEF = _features_typedef,
6272
# keep sorted
73+
headers_abi3 = True,
6374
precompile = True,
6475
py_info_venv_symlinks = True,
6576
uses_builtin_rules = not config.enable_pystar,

python/private/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ filegroup(
3131
name = "distribution",
3232
srcs = glob(["**"]) + [
3333
"//python/private/api:distribution",
34+
"//python/private/cc:distribution",
3435
"//python/private/pypi:distribution",
3536
"//python/private/whl_filegroup:distribution",
3637
"//tools/build_defs/python/private:distribution",
@@ -360,6 +361,7 @@ bzl_library(
360361
":common_labels.bzl",
361362
":py_cc_toolchain_info_bzl",
362363
":rules_cc_srcs_bzl",
364+
":sentinel_bzl",
363365
":util_bzl",
364366
"@bazel_skylib//rules:common_settings",
365367
],

0 commit comments

Comments
 (0)