Skip to content

Commit

Permalink
chore: use rules_python's py_runtime in generated toolchains
Browse files Browse the repository at this point in the history
This makes rules_python compatible with disabling using the native rules
in Bazel.

Work towards bazelbuild#1069
  • Loading branch information
rickeylev committed Dec 14, 2023
1 parent bbec4c2 commit f79ecad
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation
examples/pip_parse/bazel-pip_parse
examples/py_proto_library/bazel-py_proto_library
tests/ignore_root_user_error/bazel-ignore_root_user_error
tests/pip_repository_entry_points/bazel-pip_repository_entry_points
2 changes: 2 additions & 0 deletions python/private/common/py_runtime_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ interpreter.
# Example
```
load("@rules_python//python:py_runtime.bzl", "py_runtime")
py_runtime(
name = "python-2.7.12",
files = glob(["python-2.7.12/**"]),
Expand Down
3 changes: 2 additions & 1 deletion python/private/py_runtime_pair_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ Example usage:
```python
# In your BUILD file...
load("@rules_python//python:defs.bzl", "py_runtime_pair")
load("@rules_python//python:py_runtime.bzl", "py_runtime")
load("@rules_python//python:py_runtime_pair.bzl", "py_runtime_pair")
py_runtime(
name = "my_py2_runtime",
Expand Down
3 changes: 2 additions & 1 deletion python/py_runtime_pair.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def py_runtime_pair(name, py2_runtime = None, py3_runtime = None, **attrs):
```python
# In your BUILD file...
load("@rules_python//python:defs.bzl", "py_runtime_pair")
load("@rules_python//python:py_runtime.bzl", "py_runtime")
load("@rules_python//python:py_runtime_pair.bzl", "py_runtime_pair")
py_runtime(
name = "my_py3_runtime",
Expand Down
3 changes: 2 additions & 1 deletion python/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ def _python_repository_impl(rctx):
build_content = """\
# Generated by python/repositories.bzl
load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair")
load("@rules_python//python:py_runtime.bzl", "py_runtime")
load("@rules_python//python:py_runtime_pair.bzl", "py_runtime_pair")
load("@rules_python//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain")
package(default_visibility = ["//visibility:public"])
Expand Down

0 comments on commit f79ecad

Please sign in to comment.