From e98a494e7d2ae0b776c97b53e62ab8db30426a80 Mon Sep 17 00:00:00 2001 From: Romain Chossart Date: Wed, 3 Jul 2024 14:33:16 +0100 Subject: [PATCH] build: use http_archive for the stdlib list The `http_file` repo rules relied on Github-specific per-file HTTP API. Change this to use an `http_archive` repo rule, which refers to a simple URL containing the source tarball for stdlib-list. --- gazelle/MODULE.bazel | 6 +----- gazelle/deps.bzl | 37 +++++++------------------------------ gazelle/python/BUILD.bazel | 12 ++++++------ 3 files changed, 14 insertions(+), 41 deletions(-) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index 1829d248b2..0418b39036 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -31,9 +31,5 @@ use_repo( python_stdlib_list = use_extension("//python:extensions.bzl", "python_stdlib_list") use_repo( python_stdlib_list, - "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", + "python_stdlib_list", ) diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index f4f4c24fc7..948d61e5ae 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -18,7 +18,7 @@ load( "@bazel_gazelle//:deps.bzl", _go_repository = "go_repository", ) -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def go_repository(name, **kwargs): if name not in native.existing_rules(): @@ -26,35 +26,12 @@ def go_repository(name, **kwargs): def python_stdlib_list_deps(): "Fetch python stdlib list dependencies" - 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", + http_archive( + name = "python_stdlib_list", + build_file_content = """exports_files(glob(["stdlib_list/lists/*.txt"]))""", + sha256 = "3f6fc8fba0a99ce8fa76c1b794a24f38962f6275ea9d5cfb43a874abe472571e", + strip_prefix = "stdlib-list-0.10.0", + url = "https://github.com/pypi/stdlib-list/releases/download/v0.10.0/v0.10.0.tar.gz", ) def gazelle_deps(): diff --git a/gazelle/python/BUILD.bazel b/gazelle/python/BUILD.bazel index 195c77623d..627a867c68 100644 --- a/gazelle/python/BUILD.bazel +++ b/gazelle/python/BUILD.bazel @@ -52,13 +52,13 @@ copy_file( name = "stdlib_list", src = select( { - "@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", - "@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//:stdlib_list/lists/3.10.txt", + "@rules_python//python/config_settings:is_python_3.11": "@python_stdlib_list//:stdlib_list/lists/3.11.txt", + "@rules_python//python/config_settings:is_python_3.12": "@python_stdlib_list//:stdlib_list/lists/3.12.txt", + "@rules_python//python/config_settings:is_python_3.8": "@python_stdlib_list//:stdlib_list/lists/3.8.txt", + "@rules_python//python/config_settings:is_python_3.9": "@python_stdlib_list//:stdlib_list/lists/3.9.txt", # This is the same behaviour as previously - "//conditions:default": "@python_stdlib_list_3_11//file", + "//conditions:default": "@python_stdlib_list//:stdlib_list/lists/3.11.txt", }, ), out = "stdlib_list.txt",