Skip to content

Commit 54de779

Browse files
authored
Merge branch 'main' into docs.style
2 parents f5a83d1 + a79bbfa commit 54de779

Some content is hidden

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

51 files changed

+1765
-183
lines changed

.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/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,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma
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,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma
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,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma
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,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma
99

1010
test --test_output=errors
1111

CHANGELOG.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,14 @@ END_UNRELEASED_TEMPLATE
7272
* The `sys._base_executable` value will reflect the underlying interpreter,
7373
not venv interpreter.
7474
* The {obj}`//python/runtime_env_toolchains:all` toolchain now works with it.
75+
* (rules) Better handle flakey platform.win32_ver() calls by calling them
76+
multiple times.
7577

7678
{#v0-0-0-added}
7779
### Added
78-
* Nothing added.
80+
* Repo utilities `execute_unchecked`, `execute_checked`, and `execute_checked_stdout` now
81+
support `log_stdout` and `log_stderr` keyword arg booleans. When these are `True`
82+
(the default), the subprocess's stdout/stderr will be logged.
7983

8084
{#v0-0-0-removed}
8185
### Removed
@@ -99,8 +103,6 @@ END_UNRELEASED_TEMPLATE
99103
* 3.12.9
100104
* 3.13.2
101105
* (pypi) Use `xcrun xcodebuild --showsdks` to find XCode root.
102-
* (pypi) The `bzlmod` extension will now generate smaller lock files for when
103-
using `experimental_index_url`.
104106
* (toolchains) Remove all but `3.8.20` versions of the Python `3.8` interpreter who has
105107
reached EOL. If users still need other versions of the `3.8` interpreter, please supply
106108
the URLs manually {bzl:obj}`python.toolchain` or {bzl:obj}`python_register_toolchains` calls.
@@ -116,13 +118,6 @@ END_UNRELEASED_TEMPLATE
116118
[PR #2746](https://github.com/bazel-contrib/rules_python/pull/2746).
117119
* (rules) {attr}`py_binary.srcs` and {attr}`py_test.srcs` is no longer mandatory when
118120
`main_module` is specified (for `--bootstrap_impl=script`)
119-
* (pypi) From now on the `Requires-Dist` from the wheel metadata is analysed in
120-
the loading phase instead of repository rule phase giving better caching
121-
performance when the target platforms are changed (e.g. target python
122-
versions). This is preparatory work for stabilizing the cross-platform wheel
123-
support. From now on the usage of `experimental_target_platforms` should be
124-
avoided and the `requirements_by_platform` values should be instead used to
125-
specify the target platforms for the given dependencies.
126121

127122
[20250317]: https://github.com/astral-sh/python-build-standalone/releases/tag/20250317
128123

@@ -144,6 +139,13 @@ END_UNRELEASED_TEMPLATE
144139
* (packaging) An empty `requires_file` is treated as if it were omitted, resulting in a valid `METADATA` file.
145140
* (rules) py_wheel and sphinxdocs rules now propagate `target_compatible_with` to all targets they create.
146141
[PR #2788](https://github.com/bazel-contrib/rules_python/pull/2788).
142+
* (pypi) Correctly handle `METADATA` entries when `python_full_version` is used in
143+
the environment marker.
144+
Fixes [#2319](https://github.com/bazel-contrib/rules_python/issues/2319).
145+
* (pypi) Correctly handle `python_version` parameter and transition the requirement
146+
locking to the right interpreter version when using
147+
{obj}`compile_pip_requirements` rule.
148+
See [#2819](https://github.com/bazel-contrib/rules_python/pull/2819).
147149

148150
{#1-4-0-added}
149151
### Added

docs/environment-variables.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,19 @@ When `1`, the rules_python will warn users about deprecated functionality that w
4646
be removed in a subsequent major `rules_python` version. Defaults to `0` if unset.
4747
:::
4848

49-
:::{envvar} RULES_PYTHON_ENABLE_PYSTAR
49+
::::{envvar} RULES_PYTHON_ENABLE_PYSTAR
5050

5151
When `1`, the rules_python Starlark implementation of the core rules is used
52-
instead of the Bazel-builtin rules. Note this requires Bazel 7+.
52+
instead of the Bazel-builtin rules. Note this requires Bazel 7+. Defaults
53+
to `1`.
54+
55+
:::{versionadded} 0.26.0
56+
Defaults to `0` if unspecified.
57+
:::
58+
:::{versionchanged} 0.40.0
59+
The default became `1` if unspecified
5360
:::
61+
::::
5462

5563
::::{envvar} RULES_PYTHON_EXTRACT_ROOT
5664

docs/toolchains.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,10 @@ runtime metadata (Python version, headers, ABI flags, etc) that the regular
339339
remotely downloaded runtimes contain, which makes it possible to build e.g. C
340340
extensions (unlike the autodetecting and runtime environment toolchains).
341341

342-
For simple cases, some rules are provided that will introspect
343-
a Python installation and create an appropriate Bazel definition from
344-
it. To do this, three pieces need to be wired together:
342+
For simple cases, the {obj}`local_runtime_repo` and
343+
{obj}`local_runtime_toolchains_repo` rules are provided that will introspect a
344+
Python installation and create an appropriate Bazel definition from it. To do
345+
this, three pieces need to be wired together:
345346

346347
1. Specify a path or command to a Python interpreter (multiple can be defined).
347348
2. Create toolchains for the runtimes in (1)

examples/bzlmod/entry_points/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("@python_versions//3.9:defs.bzl", py_console_script_binary_3_9 = "py_console_script_binary")
21
load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary")
32

43
# This is how you can define a `pylint` entrypoint which uses the default python version.
@@ -24,10 +23,11 @@ py_console_script_binary(
2423
],
2524
)
2625

27-
# A specific Python version can be forced by using the generated version-aware
28-
# wrappers, e.g. to force Python 3.9:
29-
py_console_script_binary_3_9(
26+
# A specific Python version can be forced by passing `python_version`
27+
# attribute, e.g. to force Python 3.9:
28+
py_console_script_binary(
3029
name = "yamllint",
3130
pkg = "@pip//yamllint:pkg",
31+
python_version = "3.9",
3232
visibility = ["//entry_points:__subpackages__"],
3333
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
websockets
1+
websockets ; python_full_version > "3.9.1"

examples/multi_python_versions/requirements/requirements_lock_3_10.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# bazel run //requirements:requirements_3_10.update
66
#
7-
websockets==11.0.3 \
7+
websockets==11.0.3 ; python_full_version > "3.9.1" \
88
--hash=sha256:01f5567d9cf6f502d655151645d4e8b72b453413d3819d2b6f1185abc23e82dd \
99
--hash=sha256:03aae4edc0b1c68498f41a6772d80ac7c1e33c06c6ffa2ac1c27a07653e79d6f \
1010
--hash=sha256:0ac56b661e60edd453585f4bd68eb6a29ae25b5184fd5ba51e97652580458998 \

examples/multi_python_versions/requirements/requirements_lock_3_11.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# bazel run //requirements:requirements_3_11.update
66
#
7-
websockets==11.0.3 \
7+
websockets==11.0.3 ; python_full_version > "3.9.1" \
88
--hash=sha256:01f5567d9cf6f502d655151645d4e8b72b453413d3819d2b6f1185abc23e82dd \
99
--hash=sha256:03aae4edc0b1c68498f41a6772d80ac7c1e33c06c6ffa2ac1c27a07653e79d6f \
1010
--hash=sha256:0ac56b661e60edd453585f4bd68eb6a29ae25b5184fd5ba51e97652580458998 \

examples/multi_python_versions/requirements/requirements_lock_3_9.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# bazel run //requirements:requirements_3_9.update
66
#
7-
websockets==11.0.3 \
7+
websockets==11.0.3 ; python_full_version > "3.9.1" \
88
--hash=sha256:01f5567d9cf6f502d655151645d4e8b72b453413d3819d2b6f1185abc23e82dd \
99
--hash=sha256:03aae4edc0b1c68498f41a6772d80ac7c1e33c06c6ffa2ac1c27a07653e79d6f \
1010
--hash=sha256:0ac56b661e60edd453585f4bd68eb6a29ae25b5184fd5ba51e97652580458998 \

python/private/pypi/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ bzl_library(
103103
"//python/private:version_label_bzl",
104104
"@bazel_features//:features",
105105
"@pythons_hub//:interpreters_bzl",
106+
"@pythons_hub//:versions_bzl",
106107
],
107108
)
108109

@@ -220,7 +221,9 @@ bzl_library(
220221
":pep508_evaluate_bzl",
221222
":pep508_platform_bzl",
222223
":pep508_requirement_bzl",
224+
"//python/private:full_version_bzl",
223225
"//python/private:normalize_name_bzl",
226+
"@pythons_hub//:versions_bzl",
224227
],
225228
)
226229

@@ -280,6 +283,7 @@ bzl_library(
280283
":evaluate_markers_bzl",
281284
":parse_requirements_bzl",
282285
":pip_repository_attrs_bzl",
286+
":pypi_repo_utils_bzl",
283287
":render_pkg_aliases_bzl",
284288
":whl_config_setting_bzl",
285289
"//python/private:normalize_name_bzl",

0 commit comments

Comments
 (0)