Skip to content

Commit 1eebc2a

Browse files
committed
fix(rules): remove rules_python --incompatible_python_disallow_native_rules checking (#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 #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 #2326 Fixes #1645
1 parent 0c0492d commit 1eebc2a

File tree

21 files changed

+23
-83
lines changed

21 files changed

+23
-83
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
@@ -26,7 +26,9 @@ A brief description of the categories of changes:
2626
- Nothing yet
2727

2828
### Fixed
29-
- Nothing yet
29+
* (rules) Setting `--incompatible_python_disallow_native_rules` no longer
30+
causes rules_python rules to fail.
31+
([#2326](https://github.com/bazelbuild/rules_python/issues/2326).
3032

3133
### Added
3234
- Nothing yet

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_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

examples/pip_repository_annotations/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ try-import %workspace%/user.bazelrc
44
# This example is WORKSPACE specific. The equivalent functionality
55
# is in examples/bzlmod as the `whl_mods` feature.
66
build --experimental_enable_bzlmod=false
7+
common:bazel7.x --incompatible_python_disallow_native_rules

0 commit comments

Comments
 (0)