Skip to content

Commit 719202b

Browse files
BrianSongtfx-copybara
authored andcommitted
Support M1 Mac for MLMD OSS. #143
Update Bazel settings to support both macos and macos_arm64. Use the bazel_skylib library for config selects. Reflect changes in setup.py. PiperOrigin-RevId: 432116433
1 parent 70b9bf6 commit 719202b

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ build --incompatible_restrict_string_escapes=false
2424
# parameter 'user_link_flags' is deprecated and will be removed soon.
2525
# It may be temporarily re-enabled by setting --incompatible_require_linker_input_cc_api=false
2626
build --incompatible_require_linker_input_cc_api=false
27+
build:macos --apple_platform_type=macos
28+
build:macos_arm64 --cpu=darwin_arm64

ml_metadata/BUILD

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
licenses(["notice"]) # Apache 2.0
22

3+
load("@bazel_skylib//lib:selects.bzl", "selects")
4+
35
package(default_visibility = ["//visibility:public"])
46

57
config_setting(
@@ -10,9 +12,26 @@ config_setting(
1012
)
1113

1214
config_setting(
15+
name = "macos_x86_64",
16+
values = {
17+
"apple_platform_type": "macos",
18+
"cpu": "darwin",
19+
},
20+
)
21+
22+
config_setting(
23+
name = "macos_arm64",
24+
values = {
25+
"apple_platform_type": "macos",
26+
"cpu": "darwin_arm64",
27+
},
28+
)
29+
30+
selects.config_setting_group(
1331
name = "macos",
14-
constraint_values = [
15-
"@bazel_tools//platforms:osx",
32+
match_any = [
33+
":macos_x86_64",
34+
":macos_arm64",
1635
],
1736
)
1837

setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ def finalize_options(self):
9191
'installation instruction.')
9292
self._additional_build_options = []
9393
if platform.system() == 'Darwin':
94-
# Minimum macOS version 10.14 is needed to be compatible with c++17.
95-
self._additional_build_options = ['--macos_minimum_os=10.14']
94+
# This flag determines the platform qualifier of the macos wheel.
95+
if platform.machine() == 'arm64':
96+
self._additional_build_options = ['--macos_minimum_os=11.0',
97+
'--config=macos_arm64']
98+
else:
99+
self._additional_build_options = ['--macos_minimum_os=10.14']
96100

97101
def run(self):
98102
subprocess.check_call(

0 commit comments

Comments
 (0)