1# Copyright 2023 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 15"""This module is used to construct the config settings in the BUILD file in this same package. 16""" 17 18load("@bazel_skylib//rules:common_settings.bzl", "string_flag") 19 20# buildifier: disable=unnamed-macro 21def construct_config_settings(python_versions): 22 """Constructs a set of configs for all Python versions. 23 24 Args: 25 python_versions: The Python versions supported by rules_python. 26 """ 27 string_flag( 28 name = "python_version", 29 build_setting_default = python_versions[0], 30 values = python_versions, 31 visibility = ["//visibility:public"], 32 ) 33 34 for python_version in python_versions: 35 python_version_constraint_setting = "is_python_" + python_version 36 native.config_setting( 37 name = python_version_constraint_setting, 38 flag_values = {":python_version": python_version}, 39 visibility = ["//visibility:public"], 40 ) 41