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 15"""This file contains macros to be called during WORKSPACE evaluation.""" 16 17load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive") 18load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") 19load("//python:versions.bzl", "MINOR_MAPPING", "TOOL_VERSIONS") 20load("//python/private/pypi:deps.bzl", "pypi_deps") 21load(":internal_config_repo.bzl", "internal_config_repo") 22load(":pythons_hub.bzl", "hub_repo") 23 24def http_archive(**kwargs): 25 maybe(_http_archive, **kwargs) 26 27def py_repositories(): 28 """Runtime dependencies that users must install. 29 30 This function should be loaded and called in the user's `WORKSPACE`. 31 With `bzlmod` enabled, this function is not needed since `MODULE.bazel` handles transitive deps. 32 """ 33 maybe( 34 internal_config_repo, 35 name = "rules_python_internal", 36 ) 37 maybe( 38 hub_repo, 39 name = "pythons_hub", 40 minor_mapping = MINOR_MAPPING, 41 default_python_version = "", 42 toolchain_prefixes = [], 43 toolchain_python_versions = [], 44 toolchain_set_python_version_constraints = [], 45 toolchain_user_repository_names = [], 46 python_versions = sorted(TOOL_VERSIONS.keys()), 47 ) 48 http_archive( 49 name = "bazel_skylib", 50 sha256 = "d00f1389ee20b60018e92644e0948e16e350a7707219e7a390fb0a99b6ec9262", 51 urls = [ 52 "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.0/bazel-skylib-1.7.0.tar.gz", 53 "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.0/bazel-skylib-1.7.0.tar.gz", 54 ], 55 ) 56 http_archive( 57 name = "rules_cc", 58 sha256 = "4b12149a041ddfb8306a8fd0e904e39d673552ce82e4296e96fac9cbf0780e59", 59 strip_prefix = "rules_cc-0.1.0", 60 urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.1.0/rules_cc-0.1.0.tar.gz"], 61 ) 62 63 # Needed by rules_cc, triggered by @rules_java_prebuilt in Bazel by using @rules_cc//cc:defs.bzl 64 # NOTE: This name must be com_google_protobuf until Bazel drops WORKSPACE 65 # support; Bazel itself has references to com_google_protobuf. 66 http_archive( 67 name = "com_google_protobuf", 68 sha256 = "23082dca1ca73a1e9c6cbe40097b41e81f71f3b4d6201e36c134acc30a1b3660", 69 url = "https://github.com/protocolbuffers/protobuf/releases/download/v29.0-rc2/protobuf-29.0-rc2.zip", 70 strip_prefix = "protobuf-29.0-rc2", 71 ) 72 pypi_deps() 73