Skip to content

Commit fe3d6ed

Browse files
authored
Merge branch 'main' into support_python_3.13.1
2 parents 9dd5e53 + 66a8b5b commit fe3d6ed

File tree

79 files changed

+805
-235
lines changed

Some content is hidden

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

79 files changed

+805
-235
lines changed

.bazelci/presubmit.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ buildifier:
1818
# Use a specific version to avoid skew issues when new versions are released.
1919
version: 6.1.0
2020
warnings: "all"
21-
# NOTE: Minimum supported version is 6.x for workspace; 7.x for bzlmod
21+
# NOTE: Minimum supported version is 7.x
2222
.minimum_supported_version: &minimum_supported_version
2323
# For testing minimum supported version.
2424
# NOTE: Keep in sync with //:version.bzl
25-
bazel: 6.4.0
26-
skip_in_bazel_downstream_pipeline: "Bazel 6 required"
25+
bazel: 7.x
26+
skip_in_bazel_downstream_pipeline: "Bazel 7 required"
2727
.reusable_config: &reusable_config
2828
build_targets:
2929
- "--"
@@ -34,7 +34,6 @@ buildifier:
3434
build_flags:
3535
- "--keep_going"
3636
- "--build_tag_filters=-integration-test"
37-
- "--config=bazel7.x"
3837
test_targets:
3938
- "--"
4039
- "..."
@@ -55,6 +54,7 @@ buildifier:
5554
build_flags:
5655
- "--noenable_bzlmod"
5756
- "--enable_workspace"
57+
bazel: 7.x
5858
.common_bazelinbazel_config: &common_bazelinbazel_config
5959
build_flags:
6060
- "--build_tag_filters=integration-test"
@@ -159,7 +159,6 @@ tasks:
159159
- "--enable_workspace"
160160
- "--keep_going"
161161
- "--build_tag_filters=-integration-test"
162-
- "--config=bazel7.x"
163162
test_targets:
164163
- "--"
165164
- "..."
@@ -187,7 +186,6 @@ tasks:
187186
<<: *reusable_config
188187
name: "RBE: Ubuntu, minimum Bazel"
189188
platform: rbe_ubuntu2004
190-
bazel: 7.x
191189
build_flags:
192190
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
193191
# which prevents cc toolchain autodetection from working correctly
@@ -206,6 +204,9 @@ tasks:
206204
<<: *reusable_config
207205
name: "RBE: Ubuntu"
208206
platform: rbe_ubuntu2004
207+
# TODO @aignas 2024-12-11: get the RBE working in CI for bazel 8.0
208+
# See https://github.com/bazelbuild/rules_python/issues/2499
209+
bazel: 7.x
209210
test_flags:
210211
- "--test_tag_filters=-integration-test,-acceptance-test"
211212
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
@@ -412,25 +413,21 @@ tasks:
412413
name: "examples/pip_parse_vendored: Ubuntu, workspace, minimum Bazel"
413414
working_directory: examples/pip_parse_vendored
414415
platform: ubuntu2004
415-
integration_test_pip_parse_vendored_ubuntu_min_bzlmod:
416-
<<: *minimum_supported_version
417-
<<: *reusable_build_test_all
418-
name: "examples/pip_parse_vendored: Ubuntu, bzlmod, minimum Bazel"
419-
working_directory: examples/pip_parse_vendored
420-
platform: ubuntu2004
421-
bazel: 7.x
422416
integration_test_pip_parse_vendored_ubuntu:
423417
<<: *reusable_build_test_all
418+
<<: *common_workspace_flags
424419
name: "examples/pip_parse_vendored: Ubuntu"
425420
working_directory: examples/pip_parse_vendored
426421
platform: ubuntu2004
427422
integration_test_pip_parse_vendored_debian:
428423
<<: *reusable_build_test_all
424+
<<: *common_workspace_flags
429425
name: "examples/pip_parse_vendored: Debian"
430426
working_directory: examples/pip_parse_vendored
431427
platform: debian11
432428
integration_test_pip_parse_vendored_macos:
433429
<<: *reusable_build_test_all
430+
<<: *common_workspace_flags
434431
name: "examples/pip_parse_vendored: MacOS"
435432
working_directory: examples/pip_parse_vendored
436433
platform: macos

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ common --incompatible_disallow_struct_provider_syntax
2323
# Windows makes use of runfiles for some rules
2424
build --enable_runfiles
2525

26-
# Make Bazel 6 use bzlmod by default
26+
# Make Bazel 7 use bzlmod by default
2727
common --enable_bzlmod
2828

2929
# Additional config to use for readthedocs builds.
@@ -33,6 +33,6 @@ build:rtd --stamp
3333
# Some bzl files contain repos only available under bzlmod
3434
build:rtd --enable_bzlmod
3535

36-
common:bazel7.x --incompatible_python_disallow_native_rules
36+
common --incompatible_python_disallow_native_rules
3737

3838
build --lockfile_mode=update

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.x
1+
8.x

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ repos:
4646
- id: update-deleted-packages
4747
name: Update deleted packages
4848
language: system
49-
entry: bazel run @rules_bazel_integration_test//tools:update_deleted_packages
49+
# 7.x is necessary until https://github.com/bazel-contrib/rules_bazel_integration_test/pull/414
50+
# is merged and released
51+
entry: env USE_BAZEL_VERSION=7.x bazel run @rules_bazel_integration_test//tools:update_deleted_packages
5052
files: ^((examples|tests)/.*/(MODULE.bazel|WORKSPACE|WORKSPACE.bzlmod|BUILD.bazel)|.bazelrc)$
5153
pass_filenames: false

CHANGELOG.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,38 @@ Unreleased changes template.
5353
{#v0-0-0-changed}
5454
### Changed
5555
* (toolchains) 3.13 means 3.13.1 (previously 3.13.0)
56+
* Bazel 6 support is dropped and Bazel 7.4.1 is the minimum supported
57+
version, per our Bazel support matrix. Earlier versions are not
58+
tested by CI, so functionality cannot be guaranteed.
5659

5760
{#v0-0-0-fixed}
5861
### Fixed
59-
* Nothing fixed.
62+
* (py_wheel) Use the default shell environment when building wheels to allow
63+
toolchains that search PATH to be used for the wheel builder tool.
64+
* (pypi) The requirement argument parsed to `whl_library` will now not have env
65+
marker information allowing `bazel query` to work in cases where the `whl` is
66+
available for all of the platforms and the sdist can be built. This fix is
67+
for both WORKSPACE and `bzlmod` setups.
68+
Fixes [#2450](https://github.com/bazelbuild/rules_python/issues/2450).
69+
* (gazelle) Gazelle will now correctly parse Python3.12 files that use [PEP 695 Type
70+
Parameter Syntax][pep-695]. (#2396)
71+
* (pypi) Using {bzl:obj}`pip_parse.experimental_requirement_cycles` and
72+
{bzl:obj}`pip_parse.use_hub_alias_dependencies` together now works when
73+
using WORKSPACE files.
74+
75+
[pep-695]: https://peps.python.org/pep-0695/
6076

6177
{#v0-0-0-added}
6278
### Added
63-
* (toolchains) Python 3.13.1 added
79+
* (gazelle) Added `include_stub_packages` flag to `modules_mapping`. When set to `True`, this
80+
automatically includes corresponding stub packages for third-party libraries
81+
that are present and used (e.g., `boto3``boto3-stubs`), improving
82+
type-checking support.
83+
* (pypi) Freethreaded packages are now fully supported in the
84+
{obj}`experimental_index_url` usage or the regular `pip.parse` usage.
85+
To select the free-threaded interpreter in the repo phase, please use
86+
the documented [env](/environment-variables.html) variables.
87+
Fixes [#2386](https://github.com/bazelbuild/rules_python/issues/2386).* (toolchains) Python 3.13.1 added
6488
* (toolchains) Use the latest astrahl-sh toolchain release [20241206] for Python versions:
6589
* 3.9.21
6690
* 3.10.16
@@ -71,7 +95,7 @@ Unreleased changes template.
7195

7296
{#v0-0-0-removed}
7397
### Removed
74-
* Nothing removed.
98+
* `find_requirements` in `//python:defs.bzl` has been removed.
7599

76100
{#v1-0-0}
77101
## [1.0.0] - 2024-12-05
@@ -128,7 +152,7 @@ Other changes:
128152
* (repositories): Add libs/python3.lib and pythonXY.dll to the `libpython` target
129153
defined by a repository template. This enables stable ABI builds of Python extensions
130154
on Windows (by defining Py_LIMITED_API).
131-
* (rules) `py_test` and `py_binary` targets no longer incorrectly remove the
155+
* (rules) `py_test` and `py_binary` targets no longer incorrectly remove the
132156
first `sys.path` entry when using {obj}`--bootstrap_impl=script`
133157

134158
{#v1-0-0-added}

MODULE.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ bazel_binaries.local(
150150
name = "self",
151151
path = "tests/integration/bazel_from_env",
152152
)
153-
bazel_binaries.download(version = "6.4.0")
154-
bazel_binaries.download(version = "7.4.0")
153+
bazel_binaries.download(version = "7.4.1")
154+
bazel_binaries.download(version = "8.0.0")
155155

156156
# For now, don't test with rolling, because that's Bazel 9, which is a ways
157157
# away.
@@ -162,8 +162,8 @@ use_repo(
162162
# These don't appear necessary, but are reported as direct dependencies
163163
# that should be use_repo()'d, so we add them as requested
164164
"bazel_binaries_bazelisk",
165-
"build_bazel_bazel_6_4_0",
166-
"build_bazel_bazel_7_4_0",
165+
"build_bazel_bazel_7_4_1",
166+
"build_bazel_bazel_8_0_0",
167167
# "build_bazel_bazel_rolling",
168168
"build_bazel_bazel_self",
169169
)

WORKSPACE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,37 @@ workspace(name = "rules_python")
1717
# Everything below this line is used only for developing rules_python. Users
1818
# should not copy it to their WORKSPACE.
1919

20+
# Necessary so that Bazel 9 recognizes this as rules_python and doesn't try
21+
# to load the version Bazel itself uses by default.
22+
# buildifier: disable=duplicated-name
23+
local_repository(
24+
name = "rules_python",
25+
path = ".",
26+
)
27+
2028
load("//:internal_dev_deps.bzl", "rules_python_internal_deps")
2129

2230
rules_python_internal_deps()
2331

32+
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
33+
34+
rules_java_dependencies()
35+
36+
# note that the following line is what is minimally required from protobuf for the java rules
37+
# consider using the protobuf_deps() public API from @com_google_protobuf//:protobuf_deps.bzl
38+
load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility
39+
40+
proto_bazel_features(name = "proto_bazel_features")
41+
42+
# register toolchains
43+
load("@rules_java//java:repositories.bzl", "rules_java_toolchains")
44+
45+
rules_java_toolchains()
46+
47+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
48+
49+
protobuf_deps()
50+
2451
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
2552

2653
rules_jvm_external_deps()

docs/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ alabaster==1.0.0 \
1010
--hash=sha256:c00dca57bca26fa62a6d7d0a9fcce65f3e026e9bfe33e9c538fd3fbb2144fd9e \
1111
--hash=sha256:fc6786402dc3fcb2de3cabd5fe455a2db534b371124f1f21de8731783dec828b
1212
# via sphinx
13-
astroid==3.3.5 \
14-
--hash=sha256:5cfc40ae9f68311075d27ef68a4841bdc5cc7f6cf86671b49f00607d30188e2d \
15-
--hash=sha256:a9d1c946ada25098d790e079ba2a1b112157278f3fb7e718ae6a9252f5835dc8
13+
astroid==3.3.6 \
14+
--hash=sha256:6aaea045f938c735ead292204afdb977a36e989522b7833ef6fea94de743f442 \
15+
--hash=sha256:db676dc4f3ae6bfe31cda227dc60e03438378d7a896aec57422c95634e8d722f
1616
# via sphinx-autodoc2
1717
babel==2.16.0 \
1818
--hash=sha256:368b5b98b37c06b7daf6696391c3240c938b37767d4584413e8438c5c435fa8b \

docs/toolchains.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,43 @@ existing attributes:
184184
* Adding additional Python versions via {bzl:obj}`python.single_version_override` or
185185
{bzl:obj}`python.single_version_platform_override`.
186186

187+
### Using defined toolchains from WORKSPACE
188+
189+
It is possible to use toolchains defined in `MODULE.bazel` in `WORKSPACE`. For example
190+
the following `MODULE.bazel` and `WORKSPACE` provides a working {bzl:obj}`pip_parse` setup:
191+
```starlark
192+
# File: WORKSPACE
193+
load("@rules_python//python:repositories.bzl", "py_repositories")
194+
195+
py_repositories()
196+
197+
load("@rules_python//python:pip.bzl", "pip_parse")
198+
199+
pip_parse(
200+
name = "third_party",
201+
requirements_lock = "//:requirements.txt",
202+
python_interpreter_target = "@python_3_10_host//:python",
203+
)
204+
205+
load("@third_party//:requirements.bzl", "install_deps")
206+
207+
install_deps()
208+
209+
# File: MODULE.bazel
210+
bazel_dep(name = "rules_python", version = "0.40.0")
211+
212+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
213+
214+
python.toolchain(is_default = True, python_version = "3.10")
215+
216+
use_repo(python, "python_3_10", "python_3_10_host")
217+
```
218+
219+
Note, the user has to import the `*_host` repository to use the python interpreter in the
220+
{bzl:obj}`pip_parse` and {bzl:obj}`whl_library` repository rules and once that is done
221+
users should be able to ensure the setting of the default toolchain even during the
222+
transition period when some of the code is still defined in `WORKSPACE`.
223+
187224
## Workspace configuration
188225

189226
To import rules_python in your project, you first need to add it to your
@@ -229,13 +266,11 @@ python_register_toolchains(
229266
python_version = "3.11",
230267
)
231268

232-
load("@python_3_11//:defs.bzl", "interpreter")
233-
234269
load("@rules_python//python:pip.bzl", "pip_parse")
235270

236271
pip_parse(
237272
...
238-
python_interpreter_target = interpreter,
273+
python_interpreter_target = "@python_3_11_host//:python",
239274
...
240275
)
241276
```
@@ -376,7 +411,7 @@ Here, we show an example for a semi-complicated toolchain suite, one that is:
376411
Defining toolchains for this might look something like this:
377412

378413
```
379-
# File: toolchain_impls/BUILD
414+
# File: toolchain_impl/BUILD
380415
load("@rules_python//python:py_cc_toolchain.bzl", "py_cc_toolchain")
381416
load("@rules_python//python:py_exec_tools_toolchain.bzl", "py_exec_tools_toolchain")
382417
load("@rules_python//python:py_runtime.bzl", "py_runtime")

examples/build_file_generation/.bazelrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ build --enable_runfiles
55

66
# The bzlmod version of this example is in examples/bzlmod_build_file_generation
77
# Once WORKSPACE support is dropped, this example can be entirely deleted.
8-
build --experimental_enable_bzlmod=false
9-
10-
common:bazel7.x --incompatible_python_disallow_native_rules
8+
common --noenable_bzlmod
9+
common --enable_workspace
10+
common --incompatible_python_disallow_native_rules

0 commit comments

Comments
 (0)