Skip to content

Commit 72ddf0c

Browse files
authored
fix(rules): remove rules_python --incompatible_python_disallow_native_rules checking (bazel-contrib#2327)
When --incompatible_python_disallow_native_rules is enabled, all the core rules fail with an error that rules_python should be used. This is incorrect, since the rules_python rules are being used. What's happening is bazel-contrib#2257 removed the magic migration tag when pystar is enabled, but the code to check the tag was present wasn't removed. This went unnoticed because our CI doesn't set the migration flag. To fix, remove the validation logic entirely. If we're in the rules_python implementation, then there is not need to perform this validation. It was just something copy/pasted from the original code from Bazel itself. Also update the bazelrc to always set --incompatible_python_disallow_native_rules. Fixes bazel-contrib#2326 Fixes bazel-contrib#1645
1 parent 1a92c97 commit 72ddf0c

File tree

22 files changed

+146
-206
lines changed

22 files changed

+146
-206
lines changed

.bazelci/presubmit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ buildifier:
9494
bazel: "7.x"
9595
environment:
9696
RULES_PYTHON_ENABLE_PYSTAR: "1"
97+
build_flags:
98+
- "--config=bazel7.x"
9799
test_flags:
98100
# The doc check tests fail because the Starlark implementation makes the
99101
# PyInfo and PyRuntimeInfo symbols become documented.

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +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
37+
3638
build --lockfile_mode=update

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ A brief description of the categories of changes:
3131

3232
{#v0-0-0-fixed}
3333
### Fixed
34-
- Nothing yet
34+
* (rules) Setting `--incompatible_python_disallow_native_rules` no longer
35+
causes rules_python rules to fail.
36+
([#2326](https://github.com/bazelbuild/rules_python/issues/2326).
3537

3638
{#v0-0-0-added}
3739
### Added

examples/build_file_generation/.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ build --enable_runfiles
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.
88
build --experimental_enable_bzlmod=false
9+
10+
common:bazel7.x --incompatible_python_disallow_native_rules

examples/bzlmod/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ test --test_output=errors --enable_runfiles
77

88
# Windows requires these for multi-python support:
99
build --enable_runfiles
10+
common:bazel7.x --incompatible_python_disallow_native_rules

examples/bzlmod/MODULE.bazel.lock

Lines changed: 123 additions & 123 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/bzlmod_build_file_generation/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ build --enable_runfiles
66
common --experimental_enable_bzlmod
77

88
coverage --java_runtime_version=remotejdk_11
9+
common:bazel7.x --incompatible_python_disallow_native_rules

examples/multi_python_versions/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ test --test_output=errors
44
build --enable_runfiles
55

66
coverage --java_runtime_version=remotejdk_11
7+
common:bazel7.x --incompatible_python_disallow_native_rules

examples/pip_parse/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
22
try-import %workspace%/user.bazelrc
3+
common:bazel7.x --incompatible_python_disallow_native_rules

examples/pip_parse_vendored/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ build --enable_runfiles
66
# Vendoring requirements.bzl files isn't necessary under bzlmod
77
# When workspace support is dropped, this example can be removed.
88
build --noexperimental_enable_bzlmod
9+
common:bazel7.x --incompatible_python_disallow_native_rules

0 commit comments

Comments
 (0)