Skip to content

Commit 0a9481c

Browse files
committed
Merge branch 'main' of https://github.com/bazel-contrib/rules_python into refactor.system.python.venv
2 parents 0357dad + bb75fc1 commit 0a9481c

146 files changed

Lines changed: 1887 additions & 908 deletions

File tree

Some content is hidden

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

.bazelci/presubmit.yml

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ tasks:
282282
platform: rbe_ubuntu2204
283283
# TODO @aignas 2024-12-11: get the RBE working in CI for bazel 8.0
284284
# See https://github.com/bazelbuild/rules_python/issues/2499
285-
bazel: 7.x
285+
bazel: 8.x
286286
test_flags:
287287
- "--test_tag_filters=-integration-test,-acceptance-test"
288288
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
@@ -421,33 +421,6 @@ tasks:
421421
# We don't run pip_parse_vendored under Windows as the file checked in is
422422
# generated from a repository rule containing OS-specific rendered paths.
423423

424-
# The proto example is workspace-only; bzlmod functionality is covered
425-
# by examples/bzlmod/py_proto_library
426-
integration_test_py_proto_library_ubuntu_workspace:
427-
<<: *reusable_build_test_all
428-
<<: *common_workspace_flags
429-
name: "examples/py_proto_library: Ubuntu, workspace"
430-
working_directory: examples/py_proto_library
431-
platform: ubuntu2204
432-
integration_test_py_proto_library_debian_workspace:
433-
<<: *reusable_build_test_all
434-
<<: *common_workspace_flags
435-
name: "examples/py_proto_library: Debian, workspace"
436-
working_directory: examples/py_proto_library
437-
platform: debian11
438-
integration_test_py_proto_library_macos_workspace:
439-
<<: *reusable_build_test_all
440-
<<: *common_workspace_flags
441-
name: "examples/py_proto_library: MacOS, workspace"
442-
working_directory: examples/py_proto_library
443-
platform: macos_arm64
444-
integration_test_py_proto_library_windows_workspace:
445-
<<: *reusable_build_test_all
446-
<<: *common_workspace_flags
447-
name: "examples/py_proto_library: Windows, workspace"
448-
working_directory: examples/py_proto_library
449-
platform: windows
450-
451424
integration_test_pip_repository_annotations_ubuntu_workspace:
452425
<<: *reusable_build_test_all
453426
<<: *common_workspace_flags

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ build:rtd --stamp
3838
build:rtd --enable_bzlmod
3939

4040
common --incompatible_python_disallow_native_rules
41+
common --incompatible_no_implicit_file_export
4142

4243
build --lockfile_mode=update

.bazelrc.deleted_packages

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ common --deleted_packages=examples/bzlmod/libs/my_lib
88
common --deleted_packages=examples/bzlmod/other_module
99
common --deleted_packages=examples/bzlmod/other_module/other_module/pkg
1010
common --deleted_packages=examples/bzlmod/patches
11-
common --deleted_packages=examples/bzlmod/py_proto_library
12-
common --deleted_packages=examples/bzlmod/py_proto_library/example.com/another_proto
13-
common --deleted_packages=examples/bzlmod/py_proto_library/example.com/proto
14-
common --deleted_packages=examples/bzlmod/py_proto_library/foo_external
1511
common --deleted_packages=examples/bzlmod/runfiles
1612
common --deleted_packages=examples/bzlmod/tests
1713
common --deleted_packages=examples/bzlmod/tests/other_module
@@ -22,9 +18,6 @@ common --deleted_packages=examples/multi_python_versions/tests
2218
common --deleted_packages=examples/pip_parse
2319
common --deleted_packages=examples/pip_parse_vendored
2420
common --deleted_packages=examples/pip_repository_annotations
25-
common --deleted_packages=examples/py_proto_library
26-
common --deleted_packages=examples/py_proto_library/example.com/another_proto
27-
common --deleted_packages=examples/py_proto_library/example.com/proto
2821
common --deleted_packages=gazelle
2922
common --deleted_packages=gazelle/examples/bzlmod_build_file_generation
3023
common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg

.github/workflows/publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
2828
registry_fork: bazel-contrib/bazel-central-registry
2929
attest: false
30+
# Create non-draft PRs so the BCR bazel-io bot processes them. Otherwise,
31+
# since a bazel-contrib bot, we have to wait for BCR maintainers to mark it
32+
# non-draft or approve it.
33+
draft: false
3034
permissions:
3135
contents: write
3236
secrets:

CHANGELOG.md

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,65 @@ BEGIN_UNRELEASED_TEMPLATE
4747
END_UNRELEASED_TEMPLATE
4848
-->
4949

50+
{#v0-0-0}
51+
## Unreleased
52+
53+
[0.0.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.0.0
54+
55+
{#v0-0-0-removed}
56+
### Removed
57+
* Nothing removed.
58+
59+
{#v0-0-0-changed}
60+
### Changed
61+
* (binaries/tests) The `PYTHONBREAKPOINT` environment variable is automatically inherited
62+
* (binaries/tests) The {obj}`stamp` attribute now transitions the Bazel builtin
63+
{obj}`--stamp` flag.
64+
* (pypi) Now the RECORD file patches will follow the quoted or unquoted filenames convention
65+
in order to make `pytorch` and friends easier to patch.
66+
67+
{#v0-0-0-fixed}
68+
### Fixed
69+
* (tests) No more coverage warnings are being printed if there are no sources.
70+
([#2762](https://github.com/bazel-contrib/rules_python/issues/2762))
71+
* (gazelle) Ancestor `conftest.py` files are added in addition to sibling `conftest.py`.
72+
([#3497](https://github.com/bazel-contrib/rules_python/issues/3497))
73+
74+
{#v0-0-0-added}
75+
### Added
76+
* (binaries/tests) {obj}`--debugger`: allows specifying an extra dependency
77+
to add to binaries/tests for custom debuggers.
78+
* (binaries/tests) Build information is now included in binaries and tests.
79+
Use the `bazel_binary_info` module to access it. The {flag}`--stamp` flag will
80+
add {flag}`--workspace_status` information.
81+
* (gazelle) A new directive `python_generate_pyi_deps` has been added. When
82+
`true`, a `py_*` target's `pyi_srcs` attribute will be set if any `.pyi` files
83+
that are associated with the target's `srcs` are present.
84+
([#3354](https://github.com/bazel-contrib/rules_python/issues/3354)).
85+
86+
{#v1-8-3}
87+
## [1.8.3] - 2026-01-27
88+
89+
{#v1-8-3-fixed}
90+
### Fixed
91+
* (pipstar) Fix whl extraction on Windows when bazelrc has XX flags.
92+
Fixes [#3543](https://github.com/bazel-contrib/rules_python/issues/3543).
93+
94+
{#v1-8-2}
95+
## [1.8.2] - 2026-01-24
96+
97+
{#v1-8-2-fixed}
98+
### Fixed
99+
* (venvs) relax the C library filename check to make tensorflow work
100+
Fixes [#3524](https://github.com/bazel-contrib/rules_python/issues/3529).
101+
102+
{#v1-8-1}
103+
## [1.8.1] - 2026-01-20
104+
105+
{#v1-8-1-fixed}
106+
### Fixed
107+
* (pipstar) Extra resolution that refers back to the package being resolved works again.
108+
Fixes [#3524](https://github.com/bazel-contrib/rules_python/issues/3524).
50109

51110
{#v1-8-0}
52111
## [1.8.0] - 2025-12-19
@@ -65,6 +124,23 @@ END_UNRELEASED_TEMPLATE
65124
to pass the `TOOL_VERSIONS` that include 3.8 toolchains or use the `bzlmod` APIs to add
66125
them back. This means any hub `pip.parse` calls that target `3.8` will be ignored from
67126
now on. ([#2704](https://github.com/bazel-contrib/rules_python/issues/2704))
127+
{object}`python.single_version_override`, like:
128+
129+
```starlark
130+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
131+
132+
python.single_version_override(
133+
python_version = "3.8.20",
134+
sha256 = {
135+
"aarch64-apple-darwin": "2ddfc04bdb3e240f30fb782fa1deec6323799d0e857e0b63fa299218658fd3d4",
136+
"aarch64-unknown-linux-gnu": "9d8798f9e79e0fc0f36fcb95bfa28a1023407d51a8ea5944b4da711f1f75f1ed",
137+
"x86_64-apple-darwin": "68d060cd373255d2ca5b8b3441363d5aa7cc45b0c11bbccf52b1717c2b5aa8bb",
138+
"x86_64-pc-windows-msvc": "41b6709fec9c56419b7de1940d1f87fa62045aff81734480672dcb807eedc47e",
139+
"x86_64-unknown-linux-gnu": "285e141c36f88b2e9357654c5f77d1f8fb29cc25132698fe35bb30d787f38e87",
140+
},
141+
urls = ["https://github.com/astral-sh/python-build-standalone/releases/download/20241002/cpython-{python_version}+20241002-{platform}-{build}.tar.gz"],
142+
)
143+
```
68144
* (toolchain) Remove all of the python 3.9 toolchain versions except for the `3.9.25`.
69145
This version has reached EOL and will no longer receive any security fixes, please update to
70146
`3.10` or above. ([#2704](https://github.com/bazel-contrib/rules_python/issues/2704))
@@ -92,6 +168,7 @@ END_UNRELEASED_TEMPLATE
92168
### Fixed
93169
* (gazelle) Remove {obj}`py_binary` targets with invalid `srcs`. This includes files
94170
that are not generated or regular files.
171+
[#3046](https://github.com/bazel-contrib/rules_python/pull/3046)
95172
* (runfiles) Fix incorrect Python runfiles path assumption - the existing
96173
implementation assumes that it is always four levels below the runfiles
97174
directory, leading to incorrect path checks
@@ -108,6 +185,8 @@ END_UNRELEASED_TEMPLATE
108185
* (gazelle) Fix `gazelle_python_manifest.test` so that it accesses manifest files via `runfile` path handling rather than directly ([#3397](https://github.com/bazel-contrib/rules_python/issues/3397)).
109186
* (core rules) For the system_python bootstrap, the runfiles root is added to
110187
sys.path.
188+
* (sphinxdocs) The sphinxdocs `.serve` target is now compatible with Bazel's `--symlink_prefix`
189+
flag ([#3410](https://github.com/bazel-contrib/rules_python/issues/3410)).
111190

112191
{#v1-8-0-added}
113192
### Added
@@ -2065,4 +2144,4 @@ Breaking changes:
20652144
* (pip) Create all_data_requirements alias
20662145
* Expose Python C headers through the toolchain.
20672146

2068-
[0.24.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.24.0
2147+
[0.24.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.24.0

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ use_repo(
242242
"pkgutil_nspkg2",
243243
"rules_python_runtime_env_tc_info",
244244
"somepkg_with_build_files",
245+
"whl_library_extras_direct_dep",
245246
"whl_with_build_files",
246247
)
247248

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Overview
66

77
This repository is the home of the core Python rules -- `py_library`,
8-
`py_binary`, `py_test`, `py_proto_library`, and related symbols that provide the basis for Python
8+
`py_binary`, `py_test`, and related symbols that provide the basis for Python
99
support in Bazel. It also contains package installation rules for integrating with PyPI and other indices.
1010

1111
Documentation for rules_python is at <https://rules-python.readthedocs.io> and in the

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,27 @@ This flag replaces the Bazel builtin `--build_python_zip` flag.
4545
:::
4646
::::
4747

48+
::::{bzl:flag} debugger
49+
A target for providing a custom debugger dependency.
50+
51+
This flag is roughly equivalent to putting a target in `deps`. It allows
52+
injecting a dependency into executables (`py_binary`, `py_test`) without having
53+
to modify their deps. The expectation is it points to a target that provides an
54+
alternative debugger (pudb, winpdb, debugpy, etc).
55+
56+
* Must provide {obj}`PyInfo`.
57+
* This dependency is only used for the target config, i.e. build tools don't
58+
have it added.
59+
60+
:::{note}
61+
Setting this flag adds the debugger dependency, but doesn't automatically set
62+
`PYTHONBREAKPOINT` to change `breakpoint()` behavior.
63+
:::
64+
65+
:::{versionadded} VERSION_NEXT_FEATURE
66+
:::
67+
::::
68+
4869
::::{bzl:flag} experimental_python_import_all_repositories
4970
Controls whether repository directories are added to the import path.
5071

docs/environment-variables.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ would be:
1111
python -Xaaa /path/to/file.py
1212
```
1313

14-
This feature is likely to be useful for the integration of debuggers. For example,
14+
This feature is useful for the integration of debuggers. For example,
1515
it would be possible to configure `RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS` to
1616
be set to `/path/to/debugger.py --port 12344 --file`, resulting
1717
in the command executed being:
@@ -22,6 +22,8 @@ python /path/to/debugger.py --port 12345 --file /path/to/file.py
2222

2323
:::{seealso}
2424
The {bzl:obj}`interpreter_args` attribute.
25+
26+
The guide on {any}`How to integrate a debugger`
2527
:::
2628

2729
:::{versionadded} 1.3.0

0 commit comments

Comments
 (0)