From a6d30bec1019f11f1d8c17d95dac663f1c41a9e4 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Fri, 20 Dec 2024 18:05:21 +0000 Subject: [PATCH] Add support for multiple python versions Signed-off-by: Michael Carroll --- MODULE.bazel | 34 ++++++++++++++++++++++++++-------- bazel/requirements_lock.txt | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index f833884..1bde870 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,15 +7,33 @@ bazel_dep(name = "rules_license", version = "1.0.0") bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "rules_python", version = "0.40.0") +PYTHON_VERSIONS = [ + "3.8", + "3.9", + "3.10", + "3.11", + "3.12", +] + python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.toolchain( - python_version = "3.11", -) + +[ + python.toolchain( + is_default = python_version == PYTHON_VERSIONS[-1], + python_version = python_version, + ) + for python_version in PYTHON_VERSIONS +] pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") -pip.parse( - hub_name = "xacro_python_dependencies", - python_version = "3.11", - requirements_lock = "//bazel:requirements_lock.txt", -) + +[ + pip.parse( + hub_name = "xacro_python_dependencies", + python_version = python_version, + requirements_lock = "//bazel:requirements_lock.txt", + ) + for python_version in PYTHON_VERSIONS +] + use_repo(pip, "xacro_python_dependencies") diff --git a/bazel/requirements_lock.txt b/bazel/requirements_lock.txt index ebc01d2..b12b056 100644 --- a/bazel/requirements_lock.txt +++ b/bazel/requirements_lock.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # bazel run //bazel:requirements.update