Skip to content

Upgrade rules_python to 1.7.0#27792

Closed
dabanki wants to merge 14 commits intobazelbuild:masterfrom
dabanki:pr/27498
Closed

Upgrade rules_python to 1.7.0#27792
dabanki wants to merge 14 commits intobazelbuild:masterfrom
dabanki:pr/27498

Conversation

@dabanki
Copy link
Contributor

@dabanki dabanki commented Nov 25, 2025

This is a fork of #27498.

From the comments/open items on that PR, I've:

  1. Removed the tests that were called out as not needed.
  2. Added manual tag to focus_test to avoid pickup in larger runs until issue with --experimental_enable_skyfocus is resolved.
  3. Switched failing test cases from using from bazel_tools.tools.python.runfiles import runfiles to use from python.runfiles import runfiles

There are still a couple failing tests, looking for some guidance on if these can be removed/ignored:

test_source_file_does_not_override_standard_library FAILED: Expected regexp 'I am lib!' not found.

and

1) explicitInitPy_CanBeSelectivelyDisabled(com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest)
value of      : getEmptyFilenames()
unexpected (4): pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/_foo.venv/lib/__init__.py
---
expected      : [pkg/__init__.py]
but was       : [pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/__init__.py, pkg/_foo.venv/lib/__init__.py]
	at com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest.explicitInitPy_CanBeSelectivelyDisabled(BazelPyBinaryConfiguredTargetTest.java:235)
2) explicitInitPy_CanBeGloballyDisabled(com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest)
value of      : getEmptyFilenames()
unexpected (4): pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/_foo.venv/lib/__init__.py
---
expected      : [pkg/__init__.py]
but was       : [pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/__init__.py, pkg/_foo.venv/lib/__init__.py]
	at com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest.explicitInitPy_CanBeGloballyDisabled(BazelPyBinaryConfiguredTargetTest.java:250)

@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Nov 25, 2025
@dabanki
Copy link
Contributor Author

dabanki commented Nov 25, 2025

@rickeylev Do the test modifications look okay to you? And do the failing test look important or can they also be removed?

cc @meteorcloudy

@rickeylev
Copy link
Contributor

lgtm

@dabanki
Copy link
Contributor Author

dabanki commented Nov 25, 2025

Thanks for taking a look! Do the failing tests look like legitimate issues to you?

@meteorcloudy
Copy link
Member

@bazel-io fork 9.0.0

@iancha1992 iancha1992 added team-Rules-Python Native rules for Python team-Configurability platforms, toolchains, cquery, select(), config transitions labels Dec 2, 2025
@dabanki dabanki force-pushed the pr/27498 branch 2 times, most recently from cad6ea7 to ea945c0 Compare December 2, 2025 17:11
self.ScratchFile('BUILD')

# Vendor, assert and build with no problems
self.RunBazel(['vendor', '--vendor_dir=vendor', '@@rules_python+//python/config_settings:python_path'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment that (I think) we only need this until

private static final ImmutableMap<String, String> PY_FLAG_ALIASES =
ImmutableMap.of(
// LINT.IfChange
"build_python_zip",
"@@rules_python+//python/config_settings:build_python_zip",
"incompatible_default_to_explicit_init_py",
"@@rules_python+//python/config_settings:incompatible_default_to_explicit_init_py");
// LINT.ThenChange(//src/main/java/com/google/devtools/build/lib/rules/python/PythonConfiguration.java)
/** Canonical Starlark flag aliases for {@link BazelPythonConfiguration} flags. */
// TODO: b/453809359 - Remove when Bazel 9+ can read Python flag alias definitions straight from
// rules_python's MODULE.bazel.
private static final ImmutableMap<String, String> BAZEL_PY_FLAG_ALIASES =
ImmutableMap.of(
// LINT.IfChange
"python_path",
"@@rules_python+//python/config_settings:python_path",
"experimental_python_import_all_repositories",
"@@rules_python+//python/config_settings:experimental_python_import_all_repositories");
is removed?

@copybara-service copybara-service bot closed this in fbe3009 Dec 2, 2025
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Dec 2, 2025
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Dec 2, 2025
This is a fork of bazelbuild#27498.

From the comments/open items on that PR, I've:
1. Removed the tests that were called out as not needed.
2. Added manual tag to `focus_test` to avoid pickup in larger runs until issue with `--experimental_enable_skyfocus` is resolved.
3. Switched failing test cases from using `from bazel_tools.tools.python.runfiles import runfiles` to use `from python.runfiles import runfiles`

There are still a couple failing tests, looking for some guidance on if these can be removed/ignored:
```
test_source_file_does_not_override_standard_library FAILED: Expected regexp 'I am lib!' not found.
```
and
```
1) explicitInitPy_CanBeSelectivelyDisabled(com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest)
value of      : getEmptyFilenames()
unexpected (4): pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/_foo.venv/lib/__init__.py
---
expected      : [pkg/__init__.py]
but was       : [pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/__init__.py, pkg/_foo.venv/lib/__init__.py]
	at com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest.explicitInitPy_CanBeSelectivelyDisabled(BazelPyBinaryConfiguredTargetTest.java:235)
2) explicitInitPy_CanBeGloballyDisabled(com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest)
value of      : getEmptyFilenames()
unexpected (4): pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/_foo.venv/lib/__init__.py
---
expected      : [pkg/__init__.py]
but was       : [pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/__init__.py, pkg/_foo.venv/lib/__init__.py]
	at com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest.explicitInitPy_CanBeGloballyDisabled(BazelPyBinaryConfiguredTargetTest.java:250)
```

Closes bazelbuild#27792.

PiperOrigin-RevId: 839448559
Change-Id: I888614dd92fcbc4deda63a86a452bbd94e8f1523
github-merge-queue bot pushed a commit that referenced this pull request Dec 3, 2025
This is a fork of #27498.

From the comments/open items on that PR, I've:
1. Removed the tests that were called out as not needed.
2. Added manual tag to `focus_test` to avoid pickup in larger runs until
issue with `--experimental_enable_skyfocus` is resolved.
3. Switched failing test cases from using `from
bazel_tools.tools.python.runfiles import runfiles` to use `from
python.runfiles import runfiles`

There are still a couple failing tests, looking for some guidance on if
these can be removed/ignored:
```
test_source_file_does_not_override_standard_library FAILED: Expected regexp 'I am lib!' not found.
```
and
```
1) explicitInitPy_CanBeSelectivelyDisabled(com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest)
value of      : getEmptyFilenames()
unexpected (4): pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/_foo.venv/lib/__init__.py
---
expected      : [pkg/__init__.py]
but was       : [pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/__init__.py, pkg/_foo.venv/lib/__init__.py]
	at com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest.explicitInitPy_CanBeSelectivelyDisabled(BazelPyBinaryConfiguredTargetTest.java:235)
2) explicitInitPy_CanBeGloballyDisabled(com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest)
value of      : getEmptyFilenames()
unexpected (4): pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/_foo.venv/lib/__init__.py
---
expected      : [pkg/__init__.py]
but was       : [pkg/_foo.venv/lib/python3.11/__init__.py, pkg/_foo.venv/__init__.py, pkg/_foo.venv/lib/python3.11/site-packages/__init__.py, pkg/__init__.py, pkg/_foo.venv/lib/__init__.py]
	at com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryConfiguredTargetTest.explicitInitPy_CanBeGloballyDisabled(BazelPyBinaryConfiguredTargetTest.java:250)
```

Closes #27792.

PiperOrigin-RevId: 839448559
Change-Id: I888614dd92fcbc4deda63a86a452bbd94e8f1523

Commit
fbe3009

---------

Co-authored-by: Damian Banki <[email protected]>
copybara-service bot pushed a commit that referenced this pull request Dec 9, 2025
This removes hard-coded flags `--python_path`, `--experimental_python_import_all_repositories`, and `--incompatible_remove_ctx_bazel_py_fragment`.

The first two are redefined in `rules_python` 1.7.0+ and linked into Bazel in #27792. This PR graveyards them but we can delete them outright when #27793 merges.

`--incompatible_remove_ctx_bazel_py_fragment` was added in Bazel 9 to allow toggling between the native and Starlark definitions.

By removing `--incompatible_remove_ctx_bazel_py_fragment`, this change removes the ability to revert to native definitions for post-9 Bazel.

For #26521 and bazel-contrib/rules_python#3252.

Closes #27842.

PiperOrigin-RevId: 842305784
Change-Id: If55aa925d0cd546e0671ddcb44f9e2819697b22f
copybara-service bot pushed a commit that referenced this pull request Dec 12, 2025
Related to #27842.

This removes hard-coded flags `--build_python_zip`, `--incompatible_default_to_explicit_init_py`, `--python_native_rules_allowlist`, `incompatible_python_disallow_native_rules`, and `incompatible_remove_ctx_py_fragment`.

These flags are re-difined in rules_python 1.7.0+ and linked into Bazel in #27792. This PR graveyards them but we can delete them outright when #27793 merges.

By removing --incompatible_remove_ctx_py_fragment, this change removes the ability to revert to native definitions for post-9 Bazel.

For #26521 and bazel-contrib/rules_python#3252.

Closes #27900.

PiperOrigin-RevId: 843734148
Change-Id: I1bb9624b3e5a579f6aa50663eb63ef4d7d482b57
@dabanki dabanki deleted the pr/27498 branch December 18, 2025 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Configurability platforms, toolchains, cquery, select(), config transitions team-Rules-Python Native rules for Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants