1*60517a1eSAndroid Build Coastguard Worker# Copyright 2024 The Bazel Authors. All rights reserved. 2*60517a1eSAndroid Build Coastguard Worker# 3*60517a1eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*60517a1eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*60517a1eSAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*60517a1eSAndroid Build Coastguard Worker# 7*60517a1eSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 8*60517a1eSAndroid Build Coastguard Worker# 9*60517a1eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*60517a1eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*60517a1eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*60517a1eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*60517a1eSAndroid Build Coastguard Worker# limitations under the License. 14*60517a1eSAndroid Build Coastguard Worker 15*60517a1eSAndroid Build Coastguard Worker""" 16*60517a1eSAndroid Build Coastguard WorkerEXPERIMENTAL: This is experimental and may be removed without notice 17*60517a1eSAndroid Build Coastguard Worker 18*60517a1eSAndroid Build Coastguard WorkerThis module implements the uv toolchain rule 19*60517a1eSAndroid Build Coastguard Worker""" 20*60517a1eSAndroid Build Coastguard Worker 21*60517a1eSAndroid Build Coastguard Workerload("//python/uv/private:providers.bzl", "UvToolchainInfo") 22*60517a1eSAndroid Build Coastguard Worker 23*60517a1eSAndroid Build Coastguard Workerdef _uv_toolchain_impl(ctx): 24*60517a1eSAndroid Build Coastguard Worker uv = ctx.attr.uv 25*60517a1eSAndroid Build Coastguard Worker 26*60517a1eSAndroid Build Coastguard Worker default_info = DefaultInfo( 27*60517a1eSAndroid Build Coastguard Worker files = uv.files, 28*60517a1eSAndroid Build Coastguard Worker runfiles = uv[DefaultInfo].default_runfiles, 29*60517a1eSAndroid Build Coastguard Worker ) 30*60517a1eSAndroid Build Coastguard Worker uv_toolchain_info = UvToolchainInfo( 31*60517a1eSAndroid Build Coastguard Worker uv = uv, 32*60517a1eSAndroid Build Coastguard Worker version = ctx.attr.version, 33*60517a1eSAndroid Build Coastguard Worker ) 34*60517a1eSAndroid Build Coastguard Worker 35*60517a1eSAndroid Build Coastguard Worker # Export all the providers inside our ToolchainInfo 36*60517a1eSAndroid Build Coastguard Worker # so the current_toolchain rule can grab and re-export them. 37*60517a1eSAndroid Build Coastguard Worker toolchain_info = platform_common.ToolchainInfo( 38*60517a1eSAndroid Build Coastguard Worker default_info = default_info, 39*60517a1eSAndroid Build Coastguard Worker uv_toolchain_info = uv_toolchain_info, 40*60517a1eSAndroid Build Coastguard Worker ) 41*60517a1eSAndroid Build Coastguard Worker return [ 42*60517a1eSAndroid Build Coastguard Worker default_info, 43*60517a1eSAndroid Build Coastguard Worker toolchain_info, 44*60517a1eSAndroid Build Coastguard Worker ] 45*60517a1eSAndroid Build Coastguard Worker 46*60517a1eSAndroid Build Coastguard Workeruv_toolchain = rule( 47*60517a1eSAndroid Build Coastguard Worker implementation = _uv_toolchain_impl, 48*60517a1eSAndroid Build Coastguard Worker attrs = { 49*60517a1eSAndroid Build Coastguard Worker "uv": attr.label( 50*60517a1eSAndroid Build Coastguard Worker doc = "A static uv binary.", 51*60517a1eSAndroid Build Coastguard Worker mandatory = True, 52*60517a1eSAndroid Build Coastguard Worker allow_single_file = True, 53*60517a1eSAndroid Build Coastguard Worker executable = True, 54*60517a1eSAndroid Build Coastguard Worker cfg = "target", 55*60517a1eSAndroid Build Coastguard Worker ), 56*60517a1eSAndroid Build Coastguard Worker "version": attr.string(mandatory = True, doc = "Version of the uv binary."), 57*60517a1eSAndroid Build Coastguard Worker }, 58*60517a1eSAndroid Build Coastguard Worker doc = "Defines a uv toolchain.", 59*60517a1eSAndroid Build Coastguard Worker) 60