Skip to content

Commit a18f0de

Browse files
protobuf-github-botcomius
authored andcommitted
Load Python rules everywhere in protobuf
Bazel 8's autoloads don't work in repositories where they load from. Protobuf thus needs to load Python rules. PiperOrigin-RevId: 685703304
1 parent a748b10 commit a18f0de

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

python/internal.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Internal helpers for building the Python protobuf runtime.
33
"""
44

5+
load("@rules_python//python:py_test.bzl", "py_test")
6+
57
def _remove_cross_repo_path(path):
68
components = path.split("/")
79
if components[0] == "..":
@@ -123,7 +125,7 @@ def internal_py_test(deps = [], **kwargs):
123125
deps: any additional dependencies of the test.
124126
**kwargs: arguments forwarded to py_test.
125127
"""
126-
native.py_test(
128+
py_test(
127129
imports = ["."],
128130
deps = deps + ["//python:python_test_lib"],
129131
target_compatible_with = select({

python/pb_unit_tests/pyproto_test_wrapper.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""Wrapper for another py_test to run with upb, possibly with a set of expected failures."""
22

3+
load("@rules_python//python:py_test.bzl", "py_test")
4+
35
def pyproto_test_wrapper(name, deps = []):
46
src = name + "_wrapper.py"
5-
native.py_test(
7+
py_test(
68
name = name,
79
srcs = [src],
810
legacy_create_init = False,

python/py_extension.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Macro to support py_extension """
22

33
load("@bazel_skylib//lib:selects.bzl", "selects")
4+
load("@rules_python//python:py_library.bzl", "py_library")
45

56
def py_extension(name, srcs, copts, deps = [], **kwargs):
67
"""Creates a C++ library to extend python
@@ -50,7 +51,7 @@ def py_extension(name, srcs, copts, deps = [], **kwargs):
5051
visibility = ["//python:__subpackages__"],
5152
)
5253

53-
native.py_library(
54+
py_library(
5455
name = name,
5556
data = [output_file],
5657
imports = ["."],

upb/cmake/build_defs.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
# Use of this source code is governed by a BSD-style
55
# license that can be found in the LICENSE file or at
66
# https://developers.google.com/open-source/licenses/bsd
7-
87
"""Bazel support functions related to CMake support."""
98

9+
load("@rules_python//python:py_test.bzl", "py_test")
10+
1011
def staleness_test(name, outs, generated_pattern, target_files = None, tags = [], **kwargs):
1112
"""Tests that checked-in file(s) match the contents of generated file(s).
1213
@@ -46,7 +47,7 @@ def staleness_test(name, outs, generated_pattern, target_files = None, tags = []
4647
"sed -i.bak -e 's|INSERT_FILE_LIST_HERE|" + "\\\n ".join(file_list) + "|' $@",
4748
)
4849

49-
native.py_test(
50+
py_test(
5051
name = name,
5152
srcs = [script_name],
5253
data = existing_outs + [generated_pattern % file for file in outs],

0 commit comments

Comments
 (0)