Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable macOS M1 wheel builds #166

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# This macro is needed in order for mlmd to build with ZetaSQL which can only
# be compiled upon c++17 or higher.
build --cxxopt="-std=c++17"
build --host_cxxopt="-std=c++17"

# Needed to avoid zetasql proto error.
build --protocopt=--experimental_allow_proto3_optional
Expand All @@ -23,5 +24,7 @@ build --protocopt=--experimental_allow_proto3_optional
# parameter 'user_link_flags' is deprecated and will be removed soon.
# It may be temporarily re-enabled by setting --incompatible_require_linker_input_cc_api=false
build --incompatible_require_linker_input_cc_api=false

# Support for Apple M1.
build:macos --apple_platform_type=macos
build:macos_arm64 --cpu=darwin_arm64
99 changes: 27 additions & 72 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ http_archive(
],
)


#Install bazel platform version 0.0.6
http_archive(
name = "platforms",
Expand Down Expand Up @@ -41,19 +42,24 @@ http_archive(
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()

# lts_20230125.3
ABSL_COMMIT = "c2435f8342c2d0ed8101cb43adfd605fdc52dca2"
http_archive(
name = "com_google_absl",
urls = ["https://github.com/abseil/abseil-cpp/archive/940c06c25d2953f44310b68eb8aab6114dba11fb.zip"],
strip_prefix = "abseil-cpp-940c06c25d2953f44310b68eb8aab6114dba11fb",
sha256 = "0e800799aa64d0b4d354f3ff317bbd5fbf42f3a522ab0456bb749fc8d3b67415",
sha256 = "9892836ab0d3f099b8c15076c6f4168144f452d097bd49da215fe0df36a2d48c",
strip_prefix = "abseil-cpp-%s" % ABSL_COMMIT,
urls = [
"https://github.com/abseil/abseil-cpp/archive/%s.tar.gz" % ABSL_COMMIT,
],
)

BORINGSSL_COMMIT = "adde128bd706c6caf26dd595e631871b09f40bf6"
http_archive(
name = "boringssl",
sha256 = "1188e29000013ed6517168600fc35a010d58c5d321846d6a6dfee74e4c788b45",
strip_prefix = "boringssl-7f634429a04abc48e2eb041c81c5235816c96514",
sha256 = "7fc7632ce455575025be2cac610a23377753b01a4932d94a452cf831a5b32e9e",
strip_prefix = "boringssl-%s" % BORINGSSL_COMMIT,
urls = [
"https://github.com/google/boringssl/archive/7f634429a04abc48e2eb041c81c5235816c96514.tar.gz",
"https://github.com/google/boringssl/archive/%s.tar.gz" % BORINGSSL_COMMIT,
],
)

Expand All @@ -69,10 +75,10 @@ http_archive(

http_archive(
name = "com_google_googletest",
sha256 = "ff7a82736e158c077e76188232eac77913a15dac0b22508c390ab3f88e6d6d86",
strip_prefix = "googletest-b6cd405286ed8635ece71c72f118e659f4ade3fb",
sha256 = "b976cf4fd57b318afdb1bdb27fc708904b3e4bed482859eb94ba2b4bdd077fe2",
strip_prefix = "googletest-f8d7d77c06936315286eb55f8de22cd23c188571",
urls = [
"https://github.com/google/googletest/archive/b6cd405286ed8635ece71c72f118e659f4ade3fb.zip",
"https://github.com/google/googletest/archive/f8d7d77c06936315286eb55f8de22cd23c188571.zip",
],
)

Expand All @@ -88,45 +94,25 @@ http_archive(

http_archive(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
],
)

# Needed by abseil-py by zetasql.
http_archive(
name = "six_archive",
urls = [
"http://mirror.bazel.build/pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz",
"https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz",
"http://mirror.bazel.build/pypi.python.org/packages/source/s/six/six-1.16.0.tar.gz",
"https://pypi.python.org/packages/source/s/six/six-1.16.0.tar.gz",
],
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
strip_prefix = "six-1.10.0",
sha256 = "1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
strip_prefix = "six-1.16.0",
build_file = "//ml_metadata/third_party:six.BUILD"
)

http_archive(
name = "com_google_protobuf",
sha256 = "930c2c3b5ecc6c9c12615cf5ad93f1cd6e12d0aba862b572e076259970ac3a53",
strip_prefix = "protobuf-3.21.12",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.12.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

# Needed by Protobuf.
http_archive(
name = "zlib",
build_file = "@com_google_protobuf//:third_party/zlib.BUILD",
sha256 = "d8688496ea40fb61787500e863cc63c9afcbc524468cedeb478068924eb54932",
strip_prefix = "zlib-1.2.12",
urls = ["https://github.com/madler/zlib/archive/v1.2.12.tar.gz"],
)

http_archive(
name = "pybind11_bazel",
strip_prefix = "pybind11_bazel-faf56fb3df11287f26dbc66fdedf60a2fc2c6631",
Expand All @@ -146,12 +132,6 @@ http_archive(
load("@pybind11_bazel//:python_configure.bzl", "python_configure")
python_configure(name = "local_config_python")

# Needed by @com_google_protobuf.
bind(
name = "python_headers",
actual = "@local_config_python//:python_headers",
)

# Note - use @com_github_google_re2 instead of more canonical
# @com_google_re2 for consistency with dependency grpc
# which uses @com_github_google_re2.
Expand All @@ -166,11 +146,12 @@ http_archive(
],
)

# gRPC. Official release 1.50.0. Name is required by Google APIs.
http_archive(
name = "com_github_grpc_grpc",
urls = ["https://github.com/grpc/grpc/archive/v1.46.3.tar.gz"],
sha256 = "d6cbf22cb5007af71b61c6be316a79397469c58c82a942552a62e708bce60964",
strip_prefix = "grpc-1.46.3",
sha256 = "76900ab068da86378395a8e125b5cc43dfae671e09ff6462ddfef18676e2165a",
strip_prefix = "grpc-1.50.0",
urls = ["https://github.com/grpc/grpc/archive/v1.50.0.tar.gz"],
)

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
Expand All @@ -191,34 +172,8 @@ bind(
actual = "@com_github_grpc_grpc//:grpc++",
)

# Needed by gRPC.
http_archive(
name = "build_bazel_rules_swift",
sha256 = "d0833bc6dad817a367936a5f902a0c11318160b5e80a20ece35fb85a5675c886",
strip_prefix = "rules_swift-3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8",
urls = ["https://github.com/bazelbuild/rules_swift/archive/3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8.tar.gz"],
)

http_archive(
name = "io_bazel_rules_go",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/v0.20.3/rules_go-v0.20.3.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.20.3/rules_go-v0.20.3.tar.gz",
],
sha256 = "e88471aea3a3a4f19ec1310a55ba94772d087e9ce46e41ae38ecebe17935de7b",
)

# pulled in transitively by gRPC.
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")

http_archive(
name = "bazel_gazelle",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.1/bazel-gazelle-v0.19.1.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.1/bazel-gazelle-v0.19.1.tar.gz",
],
sha256 = "86c6d481b3f7aedc1d60c1c211c6f76da282ae197c3b3160f54bd3a8f847896f",
)

load("@bazel_gazelle//:deps.bzl", "go_repository", "gazelle_dependencies")

go_repository(
Expand Down
2 changes: 1 addition & 1 deletion ml_metadata/.bazelversion
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
5.3.0
5.3.2
16 changes: 11 additions & 5 deletions ml_metadata/libmysqlclient.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ genrule(
)

config_setting(
name = "darwin",
values = {"cpu": "darwin"},
name = "macos",
constraint_values = [
"@platforms//os:osx",
],
visibility = ["//visibility:public"],
)

Expand All @@ -45,13 +47,14 @@ cc_library(
# plugins.
"plugins/auth/my_auth.c",
"plugins/auth/old_password.c",
"plugins/compress/c_zlib.c",
"plugins/pvio/pvio_socket.c",
# ssl.
"libmariadb/secure/openssl.c",
# core libmariadb
"libmariadb/ma_array.c",
"libmariadb/ma_charset.c",
"libmariadb/ma_hash.c",
"libmariadb/ma_hashtbl.c",
"libmariadb/ma_net.c",
"libmariadb/mariadb_charset.c",
"libmariadb/ma_time.c",
Expand Down Expand Up @@ -91,7 +94,10 @@ cc_library(
"-DLIBICONV_PLUG",
"-DHAVE_OPENSSL",
"-DHAVE_TLS",
],
] + select({
":macos": ["-D_XOPEN_SOURCE"],
"//conditions:default": [],
}),
includes = [
"build/include/",
"include/",
Expand All @@ -102,7 +108,7 @@ cc_library(
"-ldl",
"-lm",
] + select({
":darwin": ["-liconv"],
":macos": ["-liconv"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
Expand Down
2 changes: 1 addition & 1 deletion ml_metadata/metadata_store/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ cc_library(
":metadata_access_object_base",
":query_executor",
"@com_google_protobuf//:protobuf",

"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
Expand Down
1 change: 1 addition & 0 deletions ml_metadata/metadata_store/pywrap/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ml_metadata_pybind_extension(
"//ml_metadata/proto:metadata_store_proto",
"//ml_metadata/simple_types/proto:simple_types_proto",
"@pybind11",
"@local_config_python//:python_headers",
],
)

Expand Down
3 changes: 2 additions & 1 deletion ml_metadata/ml_metadata.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def ml_metadata_pybind_extension(
"-Wl,-exported_symbols_list,$(location %s)" % exported_symbols_file,
],
"//conditions:default": [
"-Wl,-Bsymbolic",
"-Wl,--version-script",
"$(location %s)" % version_script_file,
],
Expand All @@ -270,7 +271,7 @@ def ml_metadata_pybind_extension(
exported_symbols_file,
version_script_file,
],
features = ["-use_header_modules"],
features = ["-use_header_modules", "-parse_headers"],
linkshared = 1,
visibility = visibility,
)
Expand Down
7 changes: 4 additions & 3 deletions ml_metadata/move_generated_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ function mlmd::move_generated_files() {
cp -f ${BUILD_WORKSPACE_DIRECTORY}/${bazel_genfiles}/ml_metadata/simple_types/proto/simple_types_pb2.py \
${BUILD_WORKSPACE_DIRECTORY}/ml_metadata/simple_types/proto


MLMD_EXTENSION="ml_metadata/metadata_store/pywrap/metadata_store_extension.so"
cp -f ${BUILD_WORKSPACE_DIRECTORY}/bazel-bin/${MLMD_EXTENSION} \
${BUILD_WORKSPACE_DIRECTORY}/${MLMD_EXTENSION}
DEST_FILE="${BUILD_WORKSPACE_DIRECTORY}/${MLMD_EXTENSION}"
# remove old .so file first to avoid catastrophic failure on macOS due to codesign.
rm -f "$DEST_FILE"
cp -f ${BUILD_WORKSPACE_DIRECTORY}/bazel-bin/${MLMD_EXTENSION} "${DEST_FILE}"

chmod +w "${BUILD_WORKSPACE_DIRECTORY}/${MLMD_EXTENSION}"
}
Expand Down
4 changes: 2 additions & 2 deletions ml_metadata/mysql_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def mysql_configure():
name = "libmysqlclient",
build_file = "//ml_metadata:libmysqlclient.BUILD",
workspace_file = "//ml_metadata:libmysqlclient.WORKSPACE",
patches = ["//ml_metadata/third_party:mariadbconnector.patch"],
remote = "https://github.com/MariaDB/mariadb-connector-c.git",
tag = "v3.0.8-release",
patches = ["//ml_metadata/third_party:libmysqlclient.patch"],
tag = "v3.3.2",
)
Loading