Skip to content

Commit 1194739

Browse files
committed
Merge branch 'main' into aignas.exp.bzlmod.enable.pipstar
2 parents b8bb5fa + 726ffa2 commit 1194739

File tree

152 files changed

+3082
-1418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+3082
-1418
lines changed

.bazelci/presubmit.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,20 @@ tasks:
132132
name: "Default: Ubuntu, upcoming Bazel"
133133
platform: ubuntu2204
134134
bazel: last_rc
135+
ubuntu_rolling:
136+
name: "Default: Ubuntu, rolling Bazel"
137+
platform: ubuntu2204
138+
bazel: rolling
139+
# This is an advisory job; doesn't block merges
140+
soft_fail:
141+
- exit_status: 1
142+
- exit_status: 3
143+
test_targets:
144+
- "--"
145+
- "//tests/..."
146+
test_flags:
147+
- "--keep_going"
148+
- "--test_tag_filters=-integration-test"
135149
ubuntu_workspace:
136150
<<: *reusable_config
137151
<<: *common_workspace_flags

AGENTS.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,42 @@ 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+
30+
### bzl_library targets for bzl source files
31+
32+
* A `bzl_library` target should be defined for every `.bzl` file outside
33+
of the `tests/` directory.
34+
* They should have a single `srcs` file and be named after the file with `_bzl`
35+
appended.
36+
* Their deps should be based on the `load()` statements in the source file
37+
and refer to the `bzl_library` target containing the loaded file.
38+
* For files in rules_python: replace `.bzl` with `_bzl`.
39+
e.g. given `load("//foo:bar.bzl", ...)`, the target is `//foo:bar_bzl`.
40+
* For files outside rules_python: remove the `.bzl` suffix. e.g. given
41+
`load("@foo//foo:bar.bzl", ...)`, the target is `@foo//foo:bar`.
42+
* `bzl_library()` targets should be kept in alphabetical order by name.
43+
44+
Example:
45+
46+
```
47+
bzl_library(
48+
name = "alpha_bzl",
49+
srcs = ["alpha.bzl"],
50+
deps = [":beta_bzl"],
51+
)
52+
bzl_library(
53+
name = "beta_bzl",
54+
srcs = ["beta.bzl"]
55+
)
56+
```
57+
2258
## Building and testing
2359

2460
Tests are under the `tests/` directory.
@@ -50,7 +86,17 @@ When modifying documentation
5086
* Act as an expert in tech writing, Sphinx, MyST, and markdown.
5187
* Wrap lines at 80 columns
5288
* Use hyphens (`-`) in file names instead of underscores (`_`).
53-
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+
```
54100

55101
Generated API references can be found by:
56102
* Running `bazel build //docs:docs` and inspecting the generated files
@@ -67,3 +113,11 @@ When modifying locked/resolved requirements files:
67113

68114
When building `//docs:docs`, ignore an error about exit code 2; this is a flake,
69115
so try building again.
116+
117+
BUILD and bzl files under `tests/` should have `# buildifier: disable=bzl-visibility`
118+
trailing end-of-line comments when they load from paths containing `/private/`,
119+
e.g.
120+
121+
```
122+
load("//python/private:foo.bzl", "foo") # buildifier: disable=bzl-visibility
123+
```

CHANGELOG.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,50 @@ END_UNRELEASED_TEMPLATE
8181
length errors due to too long environment variables.
8282
* (bootstrap) {obj}`--bootstrap_impl=script` now supports the `-S` interpreter
8383
setting.
84+
* (venvs) {obj}`--vens_site_packages=yes` no longer errors when packages with
85+
overlapping files or directories are used together.
86+
([#3204](https://github.com/bazel-contrib/rules_python/issues/3204)).
8487

8588
{#v0-0-0-added}
8689
### Added
90+
* (runfiles) The Python runfiles library now supports Bazel's
91+
`--incompatible_compact_repo_mapping_manifest` flag.
8792
* (bootstrap) {obj}`--bootstrap_impl=system_python` now supports the
8893
{obj}`main_module` attribute.
8994
* (bootstrap) {obj}`--bootstrap_impl=system_python` now supports the
90-
{any}`RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS` attribute.
95+
{any}`RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS` environment variable.
96+
* (rules) The `py_binary`, `py_test`, and `py_wheel` rules now have a
97+
{obj}`config_settings` attribute to control build flags within the build graph.
98+
Custom settings can be added using {obj}`config.add_transition_setting` in
99+
`MODULE.bazel` files, or {obj}`py_repositories(transition_settings=...)` in
100+
`WORKSPACE` files. See the
101+
{ref}`common-deps-with-multiple-pypi-versions` guide on using common
102+
dependencies with multiple PyPI versions` for an example.
103+
* (toolchains) Stable ABI headers support added. To use, depend on
104+
{obj}`//python/cc:current_py_cc_headers_abi3`. This allows Windows builds
105+
a way to depend on headers without the potentially Python unstable ABI
106+
objects from the regular {obj}`//python/cc:current_py_cc_headers` target
107+
being included.
108+
* Adds {obj}`//python/cc:current_py_cc_headers_abi3`,
109+
{obj}`py_cc_toolchain.headers_abi3`, and {obj}`PyCcToolchainInfo.headers_abi3`.
110+
* {obj}`//python:features.bzl%features.headers_abi3` can be used to
111+
feature-detect the presense of the above.
112+
113+
{#v1-6-3}
114+
## [1.6.3] - 2025-09-21
115+
116+
[1.6.3]: https://github.com/bazel-contrib/rules_python/releases/tag/1.6.3
117+
118+
{#v1-6-3-fixed}
119+
### Fixed
91120

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

93129
{#v1-6-0}
94130
## [1.6.0] - 2025-08-23

MODULE.bazel

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ bazel_dep(name = "platforms", version = "0.0.11")
1313
# Use py_proto_library directly from protobuf repository
1414
bazel_dep(name = "protobuf", version = "29.0-rc2", repo_name = "com_google_protobuf")
1515

16-
internal_deps = use_extension("//python/private:internal_deps.bzl", "internal_deps")
16+
rules_python_config = use_extension("//python/extensions:config.bzl", "config")
1717
use_repo(
18-
internal_deps,
18+
rules_python_config,
1919
"pypi__build",
2020
"pypi__click",
2121
"pypi__colorama",
@@ -218,6 +218,19 @@ use_repo(
218218
"whl_with_build_files",
219219
)
220220

221+
dev_rules_python_config = use_extension(
222+
"//python/extensions:config.bzl",
223+
"config",
224+
dev_dependency = True,
225+
)
226+
dev_rules_python_config.add_transition_setting(
227+
# Intentionally add a setting already present for testing
228+
setting = "//python/config_settings:python_version",
229+
)
230+
dev_rules_python_config.add_transition_setting(
231+
setting = "//tests/multi_pypi:external_deps_name",
232+
)
233+
221234
# Add gazelle plugin so that we can run the gazelle example as an e2e integration
222235
# test and include the distribution files.
223236
local_path_override(
@@ -291,7 +304,17 @@ dev_pip.parse(
291304
python_version = "3.11",
292305
requirements_lock = "//examples/wheel:requirements_server.txt",
293306
)
294-
use_repo(dev_pip, "dev_pip", "pypiserver")
307+
dev_pip.parse(
308+
hub_name = "pypi_alpha",
309+
python_version = "3.11",
310+
requirements_lock = "//tests/multi_pypi/alpha:requirements.txt",
311+
)
312+
dev_pip.parse(
313+
hub_name = "pypi_beta",
314+
python_version = "3.11",
315+
requirements_lock = "//tests/multi_pypi/beta:requirements.txt",
316+
)
317+
use_repo(dev_pip, "dev_pip", "pypi_alpha", "pypi_beta", "pypiserver")
295318

296319
# Bazel integration test setup below
297320

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.

WORKSPACE

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ load("//:internal_dev_setup.bzl", "rules_python_internal_setup")
6969
rules_python_internal_setup()
7070

7171
load("@pythons_hub//:versions.bzl", "PYTHON_VERSIONS")
72-
load("//python:repositories.bzl", "python_register_multi_toolchains")
72+
load("//python:repositories.bzl", "py_repositories", "python_register_multi_toolchains")
73+
74+
py_repositories()
7375

7476
python_register_multi_toolchains(
7577
name = "python",
@@ -155,3 +157,26 @@ pip_parse(
155157
load("@dev_pip//:requirements.bzl", docs_install_deps = "install_deps")
156158

157159
docs_install_deps()
160+
161+
#####################
162+
# Pypi repos for //tests/multi_pypi
163+
164+
pip_parse(
165+
name = "pypi_alpha",
166+
python_interpreter_target = interpreter,
167+
requirements_lock = "//tests/multi_pypi/alpha:requirements.txt",
168+
)
169+
170+
load("@pypi_alpha//:requirements.bzl", pypi_alpha_install_deps = "install_deps")
171+
172+
pypi_alpha_install_deps()
173+
174+
pip_parse(
175+
name = "pypi_beta",
176+
python_interpreter_target = interpreter,
177+
requirements_lock = "//tests/multi_pypi/beta:requirements.txt",
178+
)
179+
180+
load("@pypi_beta//:requirements.bzl", pypi_beta_install_deps = "install_deps")
181+
182+
pypi_beta_install_deps()

docs/BUILD.bazel

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
load("@bazel_skylib//rules:build_test.bzl", "build_test")
1616
load("@dev_pip//:requirements.bzl", "requirement")
1717
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
18-
load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
1918
load("//python/uv:lock.bzl", "lock") # buildifier: disable=bzl-visibility
2019
load("//sphinxdocs:readthedocs.bzl", "readthedocs_install")
2120
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
@@ -107,6 +106,7 @@ sphinx_stardocs(
107106
"//python/cc:py_cc_toolchain_bzl",
108107
"//python/cc:py_cc_toolchain_info_bzl",
109108
"//python/entry_points:py_console_script_binary_bzl",
109+
"//python/extensions:python_bzl",
110110
"//python/local_toolchains:repos_bzl",
111111
"//python/private:attr_builders_bzl",
112112
"//python/private:builders_util_bzl",
@@ -128,12 +128,9 @@ sphinx_stardocs(
128128
"//python/uv:uv_toolchain_bzl",
129129
"//python/uv:uv_toolchain_info_bzl",
130130
] + ([
131-
# Bazel 6 + Stardoc isn't able to parse something about the python bzlmod extension
132-
"//python/extensions:python_bzl",
133-
] if IS_BAZEL_7_OR_HIGHER else []) + ([
134131
# This depends on @pythons_hub, which is only created under bzlmod,
135132
"//python/extensions:pip_bzl",
136-
] if IS_BAZEL_7_OR_HIGHER and BZLMOD_ENABLED else []),
133+
] if BZLMOD_ENABLED else []),
137134
prefix = "api/rules_python/",
138135
tags = ["docs"],
139136
target_compatible_with = _TARGET_COMPATIBLE_WITH,

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

0 commit comments

Comments
 (0)