1# Copyright 2024 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://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, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14"""Pigweed python build environment for bazel.""" 15 16load("@rules_python//python:defs.bzl", "py_binary", "py_test") 17load("//pw_build:compatibility.bzl", "incompatible_with_mcu") 18 19def pw_py_test(**kwargs): 20 """Wrapper for py_test providing some defaults. 21 22 Specifically, this wrapper, 23 24 * Defaults to setting `target_compatible_with` to 25 `incompatible_with_mcu()`. 26 27 Args: 28 **kwargs: Passed to py_test. 29 """ 30 31 # Python tests are always host only, but allow a user to override 32 # the default value. 33 if kwargs.get("target_compatible_with") == None: 34 kwargs["target_compatible_with"] = incompatible_with_mcu() 35 36 py_test(**kwargs) 37 38def pw_py_binary(**kwargs): 39 """Wrapper for py_binary providing some defaults. 40 41 Specifically, this wrapper, 42 43 * Defaults to setting `target_compatible_with` to 44 `incompatible_with_mcu()`. 45 46 Args: 47 **kwargs: Passed to py_binary. 48 """ 49 50 # Python binaries are always host only, but allow a user to override the 51 # default value. 52 if kwargs.get("target_compatible_with") == None: 53 kwargs["target_compatible_with"] = incompatible_with_mcu() 54 55 py_binary(**kwargs) 56