1# Copyright 2024 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Implementation of py_api.""" 15 16load("//python/private:py_info.bzl", "PyInfoBuilder") 17load("//python/private/api:api.bzl", "ApiImplInfo") 18 19def _py_common_api_impl(ctx): 20 _ = ctx # @unused 21 return [ApiImplInfo(impl = PyCommonApi)] 22 23py_common_api = rule( 24 implementation = _py_common_api_impl, 25 doc = "Rule implementing py_common API.", 26) 27 28def _merge_py_infos(transitive, *, direct = []): 29 builder = PyInfoBuilder() 30 builder.merge_all(transitive, direct = direct) 31 return builder.build() 32 33# Exposed for doc generation, not directly used. 34# buildifier: disable=name-conventions 35PyCommonApi = struct( 36 merge_py_infos = _merge_py_infos, 37 PyInfoBuilder = PyInfoBuilder, 38) 39