Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(PyRuntimeInfo): use builtin PyRuntimeInfo unless pystar is enabled. #1748

Merged
merged 5 commits into from
Feb 10, 2024

Conversation

rickeylev
Copy link
Collaborator

@rickeylev rickeylev commented Feb 9, 2024

This fixes the bug where the PyRuntimeInfo symbol rules_python exported wasn't matching the provider identity that py_binary actually provided.

The basic problem was, when pystar is disabled:

  • PyRuntimeInfo is the rules_python defined provider
  • py_binary is native.py_binary, which provides only the builtin PyRuntimeInfo provider.

Thus, when users loaded the rules_python PyRuntimeInfo symbol, it was referring to a provider that the underlying py_binary didn't actually provide. Pystar is always disabled on Bazel 6.4,
and enabling it for Bazel 7 will happen eminently.

This typically showed up when users had a custom rule with an attribute definition that used the rules_python PyRuntimeInfo.

To fix, only use the rules_python define PyRuntimeInfo if pystar is enabled. This ensures the providers the underlying rules are providing match the symbols that rules_python is exported.

  • Also fixes py_binary and py_test to also return the builtin PyRuntimeInfo. This
    should make the transition from the builtin symbols to the rules_python symbols a bit
    easier.

Fixes #1732

This fixes the bug where the PyRuntimeInfo symbol rules_python exported
wasn't matching the provider identity that `py_binary` actually
provided.

The basic problem was, when pystar is disabled:
 * PyRuntimeInfo is the rules_python defined provider
 * py_binary is `native.py_binary`, which provides only the builtin
   PyRuntimeInfo provider.

Thus, when users loaded the rules_python PyRuntimeInfo symbol, it was
referring to a provider that the underlying py_binary didn't actually
provide. Pystar is always disabled on Bazel 6.4, and still not enabled
for Bazel 7.

This typically showed up when users had a custom rule with an attribute
definition that used the rules_python PyRuntimeInfo.

To fix, only use the rules_python define PyRuntimeInfo if pystar is
enabled. This ensures the providers the underlying rules are providing
match the symbols that rules_python is exported.
@rickeylev rickeylev requested a review from aignas February 10, 2024 01:05
@rickeylev
Copy link
Collaborator Author

Ah hm, looks like the pystar config isn't happy with this. I'll put this back into draft and figure out what's going on.

@rickeylev rickeylev marked this pull request as draft February 10, 2024 01:07
@rickeylev rickeylev marked this pull request as ready for review February 10, 2024 04:56
@rickeylev
Copy link
Collaborator Author

Tests fix. PTAL.

It uncovered another gap in compatibility: pystar py_binary wasn't returning the builtin PyRuntimeInfo. It does now, which should allow it to (1) work with a builtin py_runtime defined toolchain, and (2) allow it to work with code that is expecting the builtin PyRuntimeInfo (i.e. users that aren't loading from rules_python).

@aignas aignas added this pull request to the merge queue Feb 10, 2024
Merged via the queue into bazelbuild:main with commit a5e17e6 Feb 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: PyRuntimeInfo provided by py_binary doesn't match PyRuntimeInfo symbol from rules_python
2 participants