From c141085616a9780c1a55108bbc17306e057e36a1 Mon Sep 17 00:00:00 2001 From: hunshcn Date: Thu, 16 May 2024 11:39:52 +0800 Subject: [PATCH] stdlib_list of multi python versions --- gazelle/MODULE.bazel | 14 +++++++++++++- gazelle/deps.bzl | 24 ++++++++++++++++++++++++ gazelle/python/BUILD.bazel | 12 +++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index f9681be3e7..410e932836 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -9,6 +9,11 @@ bazel_dep(name = "rules_python", version = "0.18.0") bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go") bazel_dep(name = "gazelle", version = "0.33.0", repo_name = "bazel_gazelle") +local_path_override( + module_name = "rules_python", + path = "..", +) + go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps") go_deps.from_file(go_mod = "//:go.mod") use_repo( @@ -24,4 +29,11 @@ use_repo( ) non_module_deps = use_extension("//:def.bzl", "non_module_deps") -use_repo(non_module_deps, "python_stdlib_list_3_11") +use_repo( + non_module_deps, + "python_stdlib_list_3_10", + "python_stdlib_list_3_11", + "python_stdlib_list_3_12", + "python_stdlib_list_3_8", + "python_stdlib_list_3_9", +) diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 31100494b5..45369c5f44 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -25,12 +25,36 @@ def go_repository(name, **kwargs): _go_repository(name = name, **kwargs) def python_stdlib_list_deps(): + http_file( + name = "python_stdlib_list_3_8", + sha256 = "ee6dc367011ff298b906dbaab408940aa57086d5f8f47278f4b7523b9aa13ae3", + url = "https://raw.githubusercontent.com/pypi/stdlib-list/8cbc2067a4a0f9eee57fb541e4cd7727724b7db4/stdlib_list/lists/3.8.txt", + downloaded_file_path = "3.8.txt", + ) + http_file( + name = "python_stdlib_list_3_9", + sha256 = "a4340e5ffe2e75bb18f548028cef6e6ac15384c44ae0a776e04dd869da1d1fd7", + url = "https://raw.githubusercontent.com/pypi/stdlib-list/8cbc2067a4a0f9eee57fb541e4cd7727724b7db4/stdlib_list/lists/3.9.txt", + downloaded_file_path = "3.9.txt", + ) + http_file( + name = "python_stdlib_list_3_10", + sha256 = "0b867738b78ac98944237de2600093a1c6ef259d1810017e46f01a29f3d199e7", + url = "https://raw.githubusercontent.com/pypi/stdlib-list/8cbc2067a4a0f9eee57fb541e4cd7727724b7db4/stdlib_list/lists/3.10.txt", + downloaded_file_path = "3.10.txt", + ) http_file( name = "python_stdlib_list_3_11", sha256 = "3c1dbf991b17178d6ed3772f4fa8f64302feaf9c3385fef328a0c7ab736a79b1", url = "https://raw.githubusercontent.com/pypi/stdlib-list/8cbc2067a4a0f9eee57fb541e4cd7727724b7db4/stdlib_list/lists/3.11.txt", downloaded_file_path = "3.11.txt", ) + http_file( + name = "python_stdlib_list_3_12", + sha256 = "6d3d53194218b43ee1d04bf9a4f0b6a9309bb59cdcaddede7d9cfe8b6835d34a", + url = "https://raw.githubusercontent.com/pypi/stdlib-list/8cbc2067a4a0f9eee57fb541e4cd7727724b7db4/stdlib_list/lists/3.12.txt", + downloaded_file_path = "3.12.txt", + ) def gazelle_deps(): go_deps() diff --git a/gazelle/python/BUILD.bazel b/gazelle/python/BUILD.bazel index f3b2dc4b03..09f0bf5b65 100644 --- a/gazelle/python/BUILD.bazel +++ b/gazelle/python/BUILD.bazel @@ -50,7 +50,17 @@ go_library( copy_file( name = "stdlib_list", - src = "@python_stdlib_list_3_11//file", + src = select( + { + "@rules_python//python/config_settings:is_python_3.8": "@python_stdlib_list_3_8//file", + "@rules_python//python/config_settings:is_python_3.9": "@python_stdlib_list_3_9//file", + "@rules_python//python/config_settings:is_python_3.10": "@python_stdlib_list_3_10//file", + "@rules_python//python/config_settings:is_python_3.11": "@python_stdlib_list_3_11//file", + "@rules_python//python/config_settings:is_python_3.12": "@python_stdlib_list_3_12//file", + # This is the same behaviour as previously + "//conditions:default": "@python_stdlib_list_3_11//file", + }, + ), out = "stdlib_list.txt", allow_symlink = True, )