blob: f3177bafaa2d9c848ef14c191faf1b3000911af0 [file] [log] [blame]
From 2b966a05925ba5b436876e33eab85e3638f192b3 Mon Sep 17 00:00:00 2001
From: Protobuf Team Bot <protobuf-github-bot@google.com>
Date: Wed, 12 Jun 2024 22:55:27 -0700
Subject: [PATCH 2/2] Add minimal Python support to MODULE.bazel
PiperOrigin-RevId: 642857334
---
MODULE.bazel | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/MODULE.bazel b/MODULE.bazel
index 71d29efcb..661636eac 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -24,3 +24,30 @@ bazel_dep(name = "zlib", version = "1.2.11")
# TODO: remove after toolchain types are moved to protobuf
bazel_dep(name = "rules_proto", version = "4.0.0")
+
+SUPPORTED_PYTHON_VERSIONS = [
+ "3.8",
+ "3.9",
+ "3.10",
+ "3.11",
+ "3.12",
+]
+python = use_extension("@rules_python//python/extensions:python.bzl", "python")
+[
+ python.toolchain(
+ is_default = python_version == SUPPORTED_PYTHON_VERSIONS[-1],
+ python_version = python_version,
+ )
+ for python_version in SUPPORTED_PYTHON_VERSIONS
+]
+use_repo(python, system_python = "python_{}".format(SUPPORTED_PYTHON_VERSIONS[-1].replace(".", "_")))
+pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
+[
+ pip.parse(
+ hub_name = "pip_deps",
+ python_version = python_version,
+ requirements_lock = "//python:requirements.txt",
+ )
+ for python_version in SUPPORTED_PYTHON_VERSIONS
+]
+use_repo(pip, "pip_deps")
--
2.45.2.505.gda0bf45e8d-goog