Skip to content

Commit 783349d

Browse files
committed
Merge branch 'main' into chore/auto-exec-groups
2 parents 4c441d3 + b9b0948 commit 783349d

Some content is hidden

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

41 files changed

+703
-1106
lines changed

.bazelci/presubmit.yml

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ buildifier:
3434
build_flags:
3535
- "--keep_going"
3636
- "--build_tag_filters=-integration-test"
37+
- "--config=bazel7.x"
3738
test_targets:
3839
- "--"
3940
- "..."
@@ -84,16 +85,6 @@ buildifier:
8485
- //tests:version_3_8_test
8586
- //tests:version_3_9_test
8687
- //tests:version_default_test
87-
.pystar_base: &pystar_base
88-
bazel: "7.x"
89-
environment:
90-
RULES_PYTHON_ENABLE_PYSTAR: "1"
91-
build_flags:
92-
- "--config=bazel7.x"
93-
test_flags:
94-
# The doc check tests fail because the Starlark implementation makes the
95-
# PyInfo and PyRuntimeInfo symbols become documented.
96-
- "--test_tag_filters=-integration-test,-doc_check_test"
9788
tasks:
9889
gazelle_extension_min:
9990
<<: *common_workspace_flags_min_bazel
@@ -139,26 +130,18 @@ tasks:
139130
name: "Default: Ubuntu, upcoming Bazel"
140131
platform: ubuntu2004
141132
bazel: last_rc
142-
pystar_ubuntu_workspace:
143-
<<: *reusable_config
144-
<<: *pystar_base
145-
name: "Default test: Ubuntu, Pystar, workspace"
146-
platform: ubuntu2004
147-
pystar_ubuntu_bzlmod:
133+
ubuntu_workspace:
148134
<<: *reusable_config
149-
<<: *pystar_base
150-
name: "Default test: Ubuntu, Pystar, bzlmod"
135+
name: "Default: Ubuntu, workspace"
151136
platform: ubuntu2004
152-
pystar_mac_workspace:
137+
mac_workspace:
153138
<<: *reusable_config
154139
<<: *common_workspace_flags
155-
<<: *pystar_base
156-
name: "Default test: Mac, Pystar, workspace"
140+
name: "Default: Mac, workspace"
157141
platform: macos
158-
pystar_windows_workspace:
142+
windows_workspace:
159143
<<: *reusable_config
160-
<<: *pystar_base
161-
name: "Default test: Windows, Pystar, workspace"
144+
name: "Default: Windows, workspace"
162145
platform: windows
163146

164147
debian:
@@ -250,6 +233,13 @@ tasks:
250233
working_directory: examples/bzlmod
251234
platform: ubuntu2004
252235
bazel: 7.x
236+
integration_test_bzlmod_ubuntu_upcoming:
237+
<<: *reusable_build_test_all
238+
<<: *coverage_targets_example_bzlmod
239+
name: "examples/bzlmod: Ubuntu, upcoming Bazel"
240+
working_directory: examples/bzlmod
241+
platform: ubuntu2004
242+
bazel: last_rc
253243
integration_test_bzlmod_debian:
254244
<<: *reusable_build_test_all
255245
<<: *coverage_targets_example_bzlmod
@@ -264,12 +254,27 @@ tasks:
264254
working_directory: examples/bzlmod
265255
platform: macos
266256
bazel: 7.x
257+
integration_test_bzlmod_macos_upcoming:
258+
<<: *reusable_build_test_all
259+
<<: *coverage_targets_example_bzlmod
260+
name: "examples/bzlmod: macOS, upcoming Bazel"
261+
working_directory: examples/bzlmod
262+
platform: macos
263+
bazel: last_rc
267264
integration_test_bzlmod_windows:
268265
<<: *reusable_build_test_all
269266
# coverage is not supported on Windows
270267
name: "examples/bzlmod: Windows"
271268
working_directory: examples/bzlmod
272269
platform: windows
270+
bazel: 7.x
271+
integration_test_bzlmod_windows_upcoming:
272+
<<: *reusable_build_test_all
273+
# coverage is not supported on Windows
274+
name: "examples/bzlmod: Windows, upcoming Bazel"
275+
working_directory: examples/bzlmod
276+
platform: windows
277+
bazel: last_rc
273278
integration_test_bzlmod_ubuntu_lockfile:
274279
<<: *reusable_build_test_all
275280
<<: *coverage_targets_example_bzlmod

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it)
55
# To update these lines, execute
66
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
7-
build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered
8-
query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered
7+
build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/python/private,gazelle/pythonconfig,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered
8+
query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/python/private,gazelle/pythonconfig,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered
99

1010
test --test_output=errors
1111

.bcr/gazelle/presubmit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ bcr_test_module:
1616
module_path: "../examples/bzlmod_build_file_generation"
1717
matrix:
1818
platform: ["debian11", "macos", "ubuntu2004", "windows"]
19-
bazel: [6.x, 7.x]
19+
# last_rc is to get latest 8.x release. Replace with 8.x when available.
20+
bazel: [7.x, last_rc]
2021
tasks:
2122
run_tests:
2223
name: "Run test module"

.bcr/presubmit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ bcr_test_module:
1616
module_path: "examples/bzlmod"
1717
matrix:
1818
platform: ["debian11", "macos", "ubuntu2004", "windows"]
19-
bazel: [6.x, 7.x]
19+
# last_rc is to get latest 8.x release. Replace with 8.x when available.
20+
bazel: [7.x, last_rc]
2021
tasks:
2122
run_tests:
2223
name: "Run test module"

CHANGELOG.md

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ Unreleased changes template.
3030
3131
{#v0-0-0-changed}
3232
### Changed
33-
* Nothing yet.
33+
* Nothing changed.
3434
3535
{#v0-0-0-fixed}
3636
### Fixed
37-
* Nothing yet.
37+
* Nothing fixed.
3838
3939
{#v0-0-0-added}
4040
### Added
41-
* Nothing yet.
41+
* Nothing added.
4242
4343
{#v0-0-0-removed}
4444
### Removed
45-
* Nothing yet.
45+
* Nothing removed.
4646
-->
4747

4848
{#v0-0-0}
@@ -52,19 +52,86 @@ Unreleased changes template.
5252

5353
{#v0-0-0-changed}
5454
### Changed
55-
* Nothing yet.
55+
56+
**Breaking**:
57+
* (toolchains) stop exposing config settings in python toolchain alias repos.
58+
Please consider depending on the flags defined in
59+
`//python/config_setting/...` and the `@platforms` package instead.
60+
* (toolchains) consumers who were depending on the `MACOS_NAME` and the `arch`
61+
attribute in the `PLATFORMS` list, please update your code to respect the new
62+
values. The values now correspond to the values available in the
63+
`@platforms//` package constraint values.
64+
* (toolchains) `host_platform` and `interpreter` constants are no longer created
65+
in the `toolchain` generated alias `.bzl` files. If you need to access the
66+
host interpreter during the `repository_rule` evaluation, please use the
67+
`@python_{version}_host//:python` targets created by
68+
{bzl:obj}`python_register_toolchains` and
69+
{bzl:obj}`python_register_multi_toolchains` macros or the {bzl:obj}`python`
70+
bzlmod extension.
71+
* (bzlmod) `pip.parse.parse_all_requirements_files` attribute has been removed.
72+
See notes in the previous versions about what to do.
73+
74+
Other changes:
75+
* (python_repository) Start honoring the `strip_prefix` field for `zstd` archives.
76+
* (pypi) {bzl:obj}`pip_parse.extra_hub_aliases` now works in WORKSPACE files.
5677

5778
{#v0-0-0-fixed}
5879
### Fixed
59-
* Nothing yet.
80+
* (toolchains) stop depending on `uname` to get the value of the host platform.
81+
* (pypi): Correctly handle multiple versions of the same package in the requirements
82+
files which is useful when including different PyTorch builds (e.g. <pytorch+cpu> vs <pytorch+cu118> ) for different target platforms.
83+
Fixes ([2337](https://github.com/bazelbuild/rules_python/issues/2337)).
84+
* (uv): Correct the sha256sum for the `uv` binary for aarch64-apple-darwin.
85+
Fixes ([2411](https://github.com/bazelbuild/rules_python/issues/2411)).
6086

6187
{#v0-0-0-added}
6288
### Added
63-
* Nothing yet.
89+
* (gazelle): Parser failures will now be logged to the terminal. Additional
90+
details can be logged by setting `GAZELLE_VERBOSE=1`.
91+
* (toolchains) allow users to select which variant of the support host toolchain
92+
they would like to use through
93+
`RULES_PYTHON_REPO_TOOLCHAIN_{VERSION}_{OS}_{ARCH}` env variable setting. For
94+
example, this allows one to use `freethreaded` python interpreter in the
95+
`repository_rule` to build a wheel from `sdist`.
96+
* (toolchain) The python interpreters targeting `muslc` libc have been added
97+
for the latest toolchain versions for each minor Python version. You can control
98+
the toolchain selection by using the
99+
{bzl:obj}`//python/config_settings:py_linux_libc` build flag.
64100

65101
{#v0-0-0-removed}
66102
### Removed
67-
* Nothing yet.
103+
* (pypi): Remove `pypi_install_dependencies` macro that has been included in
104+
{bzl:obj}`py_repositories` for a long time.
105+
* (bzlmod): Remove `DEFAULT_PYTHON_VERSION` from `interpreters.bzl` file. If
106+
you need the version, please use it from the `versions.bzl` file instead.
107+
108+
{#v0-40-0}
109+
## [0.40.0] - 2024-11-17
110+
111+
[0.40.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.40.0
112+
113+
{#v0-40-changed}
114+
### Changed
115+
* Nothing changed.
116+
117+
{#v0-40-fixed}
118+
### Fixed
119+
* (rules) Don't drop custom import paths if Bazel-builtin PyInfo is removed.
120+
([2414](https://github.com/bazelbuild/rules_python/issues/2414)).
121+
122+
{#v0-40-added}
123+
### Added
124+
* Nothing added.
125+
126+
{#v0-40-removed}
127+
### Removed
128+
* (publish) Remove deprecated `requirements.txt` for the `twine` dependencies.
129+
Please use `requirements_linux.txt` instead.
130+
* (python_repository) Use bazel's built in `zstd` support and remove attributes
131+
for customizing the `zstd` binary to be used for `zstd` archives in the
132+
{bzl:obj}`python_repository` repository_rule. This affects the
133+
{bzl:obj}`python_register_toolchains` and
134+
{bzl:obj}`python_register_multi_toolchains` callers in the `WORKSPACE`.
68135

69136
{#v0-39-0}
70137
## [0.39.0] - 2024-11-13
@@ -149,7 +216,7 @@ Unreleased changes template.
149216
* (bzlmod) The extension evaluation has been adjusted to always generate the
150217
same lock file irrespective if `experimental_index_url` is set by any module
151218
or not. To opt into this behavior, set
152-
{bzl:obj}`pip.parse.parse_all_requirements_files`, which will become the
219+
`pip.parse.parse_all_requirements_files`, which will become the
153220
default in future releases leading up to `1.0.0`. Fixes
154221
[#2268](https://github.com/bazelbuild/rules_python/issues/2268). A known
155222
issue is that it may break `bazel query` and in these use cases it is

MODULE.bazel

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bazel_dep(name = "rules_cc", version = "0.0.14")
1010
bazel_dep(name = "platforms", version = "0.0.4")
1111

1212
# Those are loaded only when using py_proto_library
13-
bazel_dep(name = "rules_proto", version = "6.0.2")
13+
bazel_dep(name = "rules_proto", version = "7.0.2")
1414
bazel_dep(name = "protobuf", version = "29.0-rc2", repo_name = "com_google_protobuf")
1515

1616
internal_deps = use_extension("//python/private:internal_deps.bzl", "internal_deps")
@@ -54,7 +54,7 @@ register_toolchains("@pythons_hub//:all")
5454
#####################
5555
# Install twine for our own runfiles wheel publishing and allow bzlmod users to use it.
5656

57-
pip = use_extension("//python/private/pypi:pip.bzl", "pip_internal")
57+
pip = use_extension("//python/extensions:pip.bzl", "pip")
5858
pip.parse(
5959
# NOTE @aignas 2024-10-26: We have an integration test that depends on us
6060
# being able to build sdists for this hub, so explicitly set this to False.
@@ -84,17 +84,7 @@ bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
8484
# We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides.
8585
bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True, repo_name = "io_bazel_rules_go")
8686
bazel_dep(name = "rules_python_gazelle_plugin", version = "0", dev_dependency = True)
87-
bazel_dep(name = "gazelle", version = "0.33.0", dev_dependency = True, repo_name = "bazel_gazelle")
88-
single_version_override(
89-
module_name = "gazelle",
90-
patch_strip = 1,
91-
patches = [
92-
# Can be removed once https://github.com/bazel-contrib/bazel-gazelle/issues/1959
93-
# is fixed and released.
94-
"patches/gazelle_native_sh.patch",
95-
],
96-
version = "0.33.0",
97-
)
87+
bazel_dep(name = "gazelle", version = "0.40.0", dev_dependency = True, repo_name = "bazel_gazelle")
9888

9989
internal_dev_deps = use_extension(
10090
"//python/private:internal_dev_deps.bzl",

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps
8686
_py_gazelle_deps()
8787

8888
# This interpreter is used for various rules_python dev-time tools
89-
load("@python//3.11.9:defs.bzl", "interpreter")
89+
interpreter = "@python_3_11_9_host//:python"
9090

9191
#####################
9292
# Install twine for our own runfiles wheel publishing.
@@ -98,7 +98,7 @@ pip_parse(
9898
name = "rules_python_publish_deps",
9999
python_interpreter_target = interpreter,
100100
requirements_darwin = "//tools/publish:requirements_darwin.txt",
101-
requirements_lock = "//tools/publish:requirements.txt",
101+
requirements_lock = "//tools/publish:requirements_linux.txt",
102102
requirements_windows = "//tools/publish:requirements_windows.txt",
103103
)
104104

docs/environment-variables.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ Determines the verbosity of logging output for repo rules. Valid values:
1515
* `TRACE`
1616
:::
1717

18+
:::{envvar} RULES_PYTHON_REPO_TOOLCHAIN_VERSION_OS_ARCH
19+
20+
Determines the python interpreter platform to be used for a particular
21+
interpreter `(version, os, arch)` triple to be used in repository rules.
22+
Replace the `VERSION_OS_ARCH` part with actual values when using, e.g.
23+
`3_13_0_linux_x86_64`. The version values must have `_` instead of `.` and the
24+
os, arch values are the same as the ones mentioned in the
25+
`//python:versions.bzl` file.
26+
:::
27+
1828
:::{envvar} RULES_PYTHON_PIP_ISOLATED
1929

2030
Determines if `--isolated` is used with pip.

docs/precompiling.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@ can use an opt-in or opt-out approach by setting its value:
3939
* targets must opt-out: `--@rules_python//python/config_settings:precompile=enabled`
4040
* targets must opt-in: `--@rules_python//python/config_settings:precompile=disabled`
4141

42+
## Pyc-only builds
43+
44+
A pyc-only build (aka "source less" builds) is when only `.pyc` files are
45+
included; the source `.py` files are not included.
46+
47+
To enable this, set
48+
{bzl:obj}`--@rules_python//python/config_settings:precompile_source_retention=omit_source`
49+
flag on the command line or the {bzl:attr}`precompile_source_retention=omit_source`
50+
attribute on specific targets.
51+
52+
The advantage of pyc-only builds are:
53+
* Fewer total files in a binary.
54+
* Imports _may_ be _slightly_ faster.
55+
56+
The disadvantages are:
57+
* Error messages will be less precise because the precise line and offset
58+
information isn't in an pyc file.
59+
* pyc files are Python major-version specific.
60+
61+
:::{note}
62+
pyc files are not a form of hiding source code. They are trivial to uncompile,
63+
and uncompiling them can recover almost the original source.
64+
:::
65+
4266
## Advanced precompiler customization
4367

4468
The default implementation of the precompiler is a persistent, multiplexed,

0 commit comments

Comments
 (0)