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
pull/18766/head
Protobuf Team Bot 2 months ago committed by Copybara-Service
parent adff00baec
commit b00dca3665
  1. 4
      python/internal.bzl
  2. 4
      python/pb_unit_tests/pyproto_test_wrapper.bzl
  3. 3
      python/py_extension.bzl
  4. 5
      upb/cmake/build_defs.bzl

@ -2,6 +2,8 @@
Internal helpers for building the Python protobuf runtime.
"""
load("@rules_python//python:py_test.bzl", "py_test")
def _remove_cross_repo_path(path):
components = path.split("/")
if components[0] == "..":
@ -123,7 +125,7 @@ def internal_py_test(deps = [], **kwargs):
deps: any additional dependencies of the test.
**kwargs: arguments forwarded to py_test.
"""
native.py_test(
py_test(
imports = ["."],
deps = deps + ["//python:python_test_lib"],
target_compatible_with = select({

@ -1,8 +1,10 @@
"""Wrapper for another py_test to run with upb, possibly with a set of expected failures."""
load("@rules_python//python:py_test.bzl", "py_test")
def pyproto_test_wrapper(name, deps = []):
src = name + "_wrapper.py"
native.py_test(
py_test(
name = name,
srcs = [src],
legacy_create_init = False,

@ -1,6 +1,7 @@
"""Macro to support py_extension """
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@rules_python//python:py_library.bzl", "py_library")
def py_extension(name, srcs, copts, deps = [], **kwargs):
"""Creates a C++ library to extend python
@ -50,7 +51,7 @@ def py_extension(name, srcs, copts, deps = [], **kwargs):
visibility = ["//python:__subpackages__"],
)
native.py_library(
py_library(
name = name,
data = [output_file],
imports = ["."],

@ -4,9 +4,10 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
"""Bazel support functions related to CMake support."""
load("@rules_python//python:py_test.bzl", "py_test")
def staleness_test(name, outs, generated_pattern, target_files = None, tags = [], **kwargs):
"""Tests that checked-in file(s) match the contents of generated file(s).
@ -46,7 +47,7 @@ def staleness_test(name, outs, generated_pattern, target_files = None, tags = []
"sed -i.bak -e 's|INSERT_FILE_LIST_HERE|" + "\\\n ".join(file_list) + "|' $@",
)
native.py_test(
py_test(
name = name,
srcs = [script_name],
data = existing_outs + [generated_pattern % file for file in outs],

Loading…
Cancel
Save