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']