From b8690fa36b5b5613ce345eca95af20ea1224a231 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 27 Jan 2023 17:59:33 +0000 Subject: [PATCH 1/6] Remove Python 2 configuration and targets Bazel is dropping support for Python 2 Work towards https://github.com/bazelbuild/bazel/issues/17293 --- examples/third_party/python/BUILD.bazel | 17 ------ .../third_party/python/BUILD.python2.bazel | 55 ------------------- examples/third_party/python/python2_test.py | 8 --- .../python/python_repositories.bzl | 10 ---- 4 files changed, 90 deletions(-) delete mode 100644 examples/third_party/python/BUILD.python2.bazel delete mode 100644 examples/third_party/python/python2_test.py diff --git a/examples/third_party/python/BUILD.bazel b/examples/third_party/python/BUILD.bazel index c0d4785e0..515718c84 100644 --- a/examples/third_party/python/BUILD.bazel +++ b/examples/third_party/python/BUILD.bazel @@ -2,19 +2,11 @@ load("@rules_python//python:defs.bzl", "py_runtime", "py_runtime_pair", "py_test exports_files( [ - "BUILD.python2.bazel", "BUILD.python3.bazel", ], visibility = ["//visibility:public"], ) -py_runtime( - name = "py2_runtime", - files = ["@python2"], - interpreter = "@python2//:python2_bin", - python_version = "PY2", -) - py_runtime( name = "py3_runtime", files = ["@python3"], @@ -24,7 +16,6 @@ py_runtime( py_runtime_pair( name = "py_runtime_pair", - py2_runtime = ":py2_runtime", py3_runtime = ":py3_runtime", ) @@ -34,13 +25,6 @@ toolchain( toolchain_type = "@rules_python//python:toolchain_type", ) -py_test( - name = "python2_test", - srcs = ["python2_test.py"], - python_version = "PY2", - visibility = ["//:__pkg__"], -) - py_test( name = "python3_test", srcs = ["python3_test.py"], @@ -51,7 +35,6 @@ py_test( test_suite( name = "python_tests", tests = [ - ":python2_test", ":python3_test", ], ) diff --git a/examples/third_party/python/BUILD.python2.bazel b/examples/third_party/python/BUILD.python2.bazel deleted file mode 100644 index b93d3f000..000000000 --- a/examples/third_party/python/BUILD.python2.bazel +++ /dev/null @@ -1,55 +0,0 @@ -load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make") - -package(default_visibility = ["//visibility:public"]) - -filegroup( - name = "all_srcs", - srcs = glob( - include = ["**"], - exclude = ["*.bazel"], - ), -) - -configure_make( - name = "python2", - build_data = select({ - "@platforms//os:macos": ["@subversion"], - "//conditions:default": [], - }), - configure_options = [ - "CFLAGS='-Dredacted=\"redacted\"'", - "--with-openssl=$EXT_BUILD_DEPS/openssl", - "--with-zlib=$EXT_BUILD_DEPS/zlib", - "--enable-optimizations", - ], - env = select({ - "@platforms//os:macos": {"AR": ""}, - "//conditions:default": {}, - }), - features = select({ - "@platforms//os:macos": ["-headerpad"], - "//conditions:default": {}, - }), - # rules_foreign_cc defaults the install_prefix to "python". This conflicts with the "python" executable that is generated. - install_prefix = "py_install", - lib_source = ":all_srcs", - out_binaries = [ - "python2.7", - ], - out_data_dirs = ["lib"], - # Building these targets rather than the default prevents tests from being run, which take a while - targets = [ - "build_all", - "altinstall", - ], - deps = [ - "@openssl", - "@zlib", - ], -) - -filegroup( - name = "python2_bin", - srcs = [":python2"], - output_group = "python2.7", -) diff --git a/examples/third_party/python/python2_test.py b/examples/third_party/python/python2_test.py deleted file mode 100644 index 1095e2537..000000000 --- a/examples/third_party/python/python2_test.py +++ /dev/null @@ -1,8 +0,0 @@ - -import sys -import platform - -if __name__ == "__main__": - - assert('python2_test.runfiles/python2/python2/bin/' in sys.executable) - assert(platform.python_version() == "2.7.18") diff --git a/examples/third_party/python/python_repositories.bzl b/examples/third_party/python/python_repositories.bzl index 2de32f5eb..69d54d364 100644 --- a/examples/third_party/python/python_repositories.bzl +++ b/examples/third_party/python/python_repositories.bzl @@ -5,16 +5,6 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=unnamed-macro def python_repositories(): - maybe( - http_archive, - name = "python2", - build_file = Label("//python:BUILD.python2.bazel"), - strip_prefix = "Python-2.7.18", - urls = [ - "https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz", - ], - sha256 = "da3080e3b488f648a3d7a4560ddee895284c3380b11d6de75edb986526b9a814", - ) maybe( http_archive, name = "python3", From 28f34ecc82469244456c5e0afd0f452db6d9f90f Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 27 Jan 2023 19:14:00 +0000 Subject: [PATCH 2/6] Raise minimum supported version to 5.0 --- .bazelci/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelci/config.yaml b/.bazelci/config.yaml index caf80f5e7..caa660538 100644 --- a/.bazelci/config.yaml +++ b/.bazelci/config.yaml @@ -201,7 +201,7 @@ tasks: - "--experimental_enable_aggregating_middleman=False" min_supported_version_examples: name: "Minimum Supported Version Examples" - bazel: "4.0.0" + bazel: "5.0.0" platform: ubuntu1804 working_directory: examples min_supported_targets: &min_supported_targets From c266517616e6d035e6bb696f6e5f36ccf0f988b3 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 27 Jan 2023 19:17:43 +0000 Subject: [PATCH 3/6] Remove --experimental_enable_aggregating_middleman Bazel 5 doesn't have this flag. --- .bazelci/config.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.bazelci/config.yaml b/.bazelci/config.yaml index caa660538..41dbbea90 100644 --- a/.bazelci/config.yaml +++ b/.bazelci/config.yaml @@ -207,12 +207,7 @@ tasks: min_supported_targets: &min_supported_targets - "//..." build_targets: *min_supported_targets - # See comment above regarding --experimental_enable_aggregating_middleman=False - build_flags: - - "--experimental_enable_aggregating_middleman=False" test_targets: *min_supported_targets - test_flags: - - "--experimental_enable_aggregating_middleman=False" buildifier: version: "5.1.0" From a6fe2f54d859c94cf1781516d219c558fe76f5f5 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 27 Jan 2023 20:18:16 +0000 Subject: [PATCH 4/6] Restore minimum supported bazel version to 4.0 --- .bazelci/config.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.bazelci/config.yaml b/.bazelci/config.yaml index 41dbbea90..caf80f5e7 100644 --- a/.bazelci/config.yaml +++ b/.bazelci/config.yaml @@ -201,13 +201,18 @@ tasks: - "--experimental_enable_aggregating_middleman=False" min_supported_version_examples: name: "Minimum Supported Version Examples" - bazel: "5.0.0" + bazel: "4.0.0" platform: ubuntu1804 working_directory: examples min_supported_targets: &min_supported_targets - "//..." build_targets: *min_supported_targets + # See comment above regarding --experimental_enable_aggregating_middleman=False + build_flags: + - "--experimental_enable_aggregating_middleman=False" test_targets: *min_supported_targets + test_flags: + - "--experimental_enable_aggregating_middleman=False" buildifier: version: "5.1.0" From 3f3ad70bc0875f35107c6baf444510cad3e3e6c5 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 27 Jan 2023 20:31:20 +0000 Subject: [PATCH 5/6] Skip //cmake_android:app for minumum versoin examples test --- .bazelci/config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelci/config.yaml b/.bazelci/config.yaml index caf80f5e7..750759597 100644 --- a/.bazelci/config.yaml +++ b/.bazelci/config.yaml @@ -206,6 +206,7 @@ tasks: working_directory: examples min_supported_targets: &min_supported_targets - "//..." + - "-//cmake_android:app" build_targets: *min_supported_targets # See comment above regarding --experimental_enable_aggregating_middleman=False build_flags: From a5d7bdc3c506dd20a92bf8e42fcbbaa45452c611 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 27 Jan 2023 20:49:01 +0000 Subject: [PATCH 6/6] Add comment explaining why the test is skipped --- .bazelci/config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bazelci/config.yaml b/.bazelci/config.yaml index 750759597..4799fe23f 100644 --- a/.bazelci/config.yaml +++ b/.bazelci/config.yaml @@ -206,6 +206,8 @@ tasks: working_directory: examples min_supported_targets: &min_supported_targets - "//..." + # Requires Python 2 under Bazel 4; skip so that Bazel 7 can disable Python 2 + # See https://github.com/bazelbuild/bazel/issues/17293 - "-//cmake_android:app" build_targets: *min_supported_targets # See comment above regarding --experimental_enable_aggregating_middleman=False