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(py_runtime): make py_runtime_pair return builtin PyRuntimeInfo under Bazel 6; make python_bootstrap_template public #1611

Merged
merged 3 commits into from
Dec 14, 2023

Conversation

rickeylev
Copy link
Collaborator

@rickeylev rickeylev commented Dec 14, 2023

This fixes two bugs from #1574:

  • Bazel 6's py_binary rejects the rules_python Starlark implemented PyRuntimeInfo.
  • python_bootstrap_template.txt isn't public; this prevents py_runtime from being
    used outside rules_python itself (e.g. in the python toolchain repos)

With Bazel 6, the py_binary rule performs a type check of the PyRuntimeInfo value it gets from the toolchain to verify it is an instance of the Java-implemented PyRuntimeInfo class. This type check fails when the provider is implemented in rules_python in Starlark.

To fix, make the py_runtime_info prefer the builtin PyRuntimeInfo provider when running under Bazel 6. The two providers are (currently) the same, so are mostly interchangable. This satisfies the type check that py_binary performs.

py_runtime as an implicit dependency on //python/private:python_bootstrap_template.txt,
but that target is only visible to rules python itself. This means the py_runtime targets
created in the toolchain repos fail. To fix, make the file public.

Fixes #1610

@rickeylev rickeylev requested a review from aignas December 14, 2023 06:53
@rickeylev rickeylev force-pushed the fix.py.runtime.bazel.6 branch from e020118 to ff9121e Compare December 14, 2023 06:53
With Bazel 6, the `py_binary` rule performs a type check of the
PyRuntimeInfo value it gets from the toolchain to verify it is an
instance of the Java-implemented PyRuntimeInfo class. This type check
fails when the provider is implemented in rules_python in Starlark.

To fix, make the `py_runtime_info` prefer the builtin PyRuntimeInfo
provider when running under Bazel 6. The two providers are (currently)
the same, so are mostly interchangable. This satisfies the type check
that `py_binary` performs.

Fixes bazelbuild#1610
@rickeylev rickeylev force-pushed the fix.py.runtime.bazel.6 branch from ff9121e to f67fca5 Compare December 14, 2023 06:55
@rickeylev rickeylev changed the title fix(py_runtime): make py_runtime_pair return builtin PyRuntimeInfo under Bazel 6 fix(py_runtime): make py_runtime_pair return builtin PyRuntimeInfo under Bazel 6; make python_bootstrap_template public Dec 14, 2023
@aignas aignas added this pull request to the merge queue Dec 14, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 14, 2023
@aignas aignas added this pull request to the merge queue Dec 14, 2023
Merged via the queue into bazelbuild:main with commit bbec4c2 Dec 14, 2023
1 check passed
@rickeylev rickeylev deleted the fix.py.runtime.bazel.6 branch December 14, 2023 17:38
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.

Starlark-based py_runtime with Bazel 6 doesn't work
2 participants