From 91c5ea797cfe2c1e6b6e39a90b3322bac6f74b66 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 24 Jun 2024 14:30:08 -0700 Subject: [PATCH 1/3] refactor: call a function to define internal pypi flags instead of listcomp This is to so tooling can more automatically process the files. In particular, it helps tools, like buildozer process the files, which makes it easier to import the code into Google. This is because there is a named target that buildozer can be told to process, whereas, with a list comprehension, it's an arbitrary chunk of code that has to be patched, without an identifiable label. --- python/config_settings/BUILD.bazel | 16 ++++------------ python/private/pypi/flags.bzl | 9 +++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/python/config_settings/BUILD.bazel b/python/config_settings/BUILD.bazel index f6f46db770..f2383d6056 100644 --- a/python/config_settings/BUILD.bazel +++ b/python/config_settings/BUILD.bazel @@ -10,10 +10,10 @@ load( ) load( "//python/private/pypi:flags.bzl", - "INTERNAL_FLAGS", "UniversalWhlFlag", "UseWhlFlag", "WhlLibcFlag", + "define_pypi_internal_flags", ) load(":config_settings.bzl", "construct_config_settings") @@ -163,14 +163,6 @@ string_flag( visibility = ["//visibility:public"], ) -# private pip whl related flags. Their values cannot be changed and they -# are an implementation detail of how `pip_config_settings` work. -[ - string_flag( - name = "_internal_pip_" + flag, - build_setting_default = "", - values = [""], - visibility = ["//visibility:public"], - ) - for flag in INTERNAL_FLAGS -] +define_pypi_internal_flags( + name = "define_pypi_internal_flags", +) diff --git a/python/private/pypi/flags.bzl b/python/private/pypi/flags.bzl index d834be8cc6..b0805bac2d 100644 --- a/python/private/pypi/flags.bzl +++ b/python/private/pypi/flags.bzl @@ -68,3 +68,12 @@ INTERNAL_FLAGS = [ "whl_pycp3x_abi3", "whl_pycp3x_abicp", ] + +def define_pypi_internal_flags(name): + for flag in INTERNAL_FLAGS: + string_flag( + name = "_internal_pip_" + flag, + build_setting_default = "", + values = [""], + visibility = ["//visibility:public"], + ) From f4326bd7c3a5b103ae71e20181423b2a8f73f514 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 24 Jun 2024 14:55:54 -0700 Subject: [PATCH 2/3] add missing load --- python/private/pypi/BUILD.bazel | 5 ++++- python/private/pypi/flags.bzl | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/python/private/pypi/BUILD.bazel b/python/private/pypi/BUILD.bazel index e7ae735531..6e17ba0d45 100644 --- a/python/private/pypi/BUILD.bazel +++ b/python/private/pypi/BUILD.bazel @@ -92,7 +92,10 @@ bzl_library( bzl_library( name = "flags_bzl", srcs = ["flags.bzl"], - deps = ["//python/private:enum_bzl"], + deps = [ + "//python/private:enum_bzl", + "@bazel_skylib//lib:common_settings", + ], ) bzl_library( diff --git a/python/private/pypi/flags.bzl b/python/private/pypi/flags.bzl index b0805bac2d..1e380625ce 100644 --- a/python/private/pypi/flags.bzl +++ b/python/private/pypi/flags.bzl @@ -18,6 +18,7 @@ NOTE: The transitive loads of this should be kept minimal. This avoids loading unnecessary files when all that are needed are flag definitions. """ +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") load("//python/private:enum.bzl", "enum") # Determines if we should use whls for third party From 3840b1c72854b22014188361b4faceeb673ec3f0 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 24 Jun 2024 14:57:35 -0700 Subject: [PATCH 3/3] fix dep --- python/private/pypi/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/private/pypi/BUILD.bazel b/python/private/pypi/BUILD.bazel index 6e17ba0d45..0960b6a21d 100644 --- a/python/private/pypi/BUILD.bazel +++ b/python/private/pypi/BUILD.bazel @@ -94,7 +94,7 @@ bzl_library( srcs = ["flags.bzl"], deps = [ "//python/private:enum_bzl", - "@bazel_skylib//lib:common_settings", + "@bazel_skylib//rules:common_settings", ], )