From c644d9aaecdf2bd2be070004d322c1e0927b2116 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Tue, 16 Jan 2024 15:24:25 +0000 Subject: [PATCH] Try to get things working again with Bazel 7. Specifically, try passing `--platforms` as well as `--cpu`. (The latter is going away eventually, but keep it for now.) Change-Id: Id53ba7b91008c7b90b1e9d242a3eded3e65007b8 Reviewed-on: https://code-review.googlesource.com/c/re2/+/62370 Reviewed-by: Paul Wankadia Reviewed-by: Alex Chernyakhovsky --- python/BUILD.bazel | 36 ++++++++++++++++++++++++++++++++++++ python/setup.py | 1 + 2 files changed, 37 insertions(+) diff --git a/python/BUILD.bazel b/python/BUILD.bazel index a05fb6ec7..48d7d3f58 100644 --- a/python/BUILD.bazel +++ b/python/BUILD.bazel @@ -34,3 +34,39 @@ py_test( "@abseil-py//absl/testing:parameterized", ], ) + +# These are implementation details for `setup.py`, so they can be +# named however we want. For now, they are named to be consistent +# with the `--cpu` flag values that they will eventually replace. + +platform( + name = "darwin_x86_64", + constraint_values = [ + "@platforms//cpu:x86_64", + "@platforms//os:macos", + ], +) + +platform( + name = "darwin_arm64", + constraint_values = [ + "@platforms//cpu:arm64", + "@platforms//os:macos", + ], +) + +platform( + name = "x64_x86_windows", + constraint_values = [ + "@platforms//cpu:x86_32", + "@platforms//os:windows", + ], +) + +platform( + name = "x64_windows", + constraint_values = [ + "@platforms//cpu:x86_64", + "@platforms//os:windows", + ], +) diff --git a/python/setup.py b/python/setup.py index 3bd11edb7..7d83b3447 100644 --- a/python/setup.py +++ b/python/setup.py @@ -54,6 +54,7 @@ def build_extension(self, ext): cmd = ['bazel', 'build'] try: cmd.append(f'--cpu={os.environ["BAZEL_CPU"].lower()}') + cmd.append(f'--platforms=//python:{os.environ["BAZEL_CPU"].lower()}') except KeyError: pass cmd += ['--compilation_mode=opt', '--', ':all']