From 6988bd0d8b25a6c50c962d4eb47714fa328cd497 Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Fri, 2 Feb 2024 16:32:45 +0100 Subject: [PATCH] bazel: try to fix pybind11_abseil build on macos --- WORKSPACE | 2 + patches/pybind11_abseil.patch | 93 +++++++++++++++++++++++++++++++++-- 2 files changed, 92 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 628381d038..f596f871f6 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -244,6 +244,8 @@ new_git_repository( new_git_repository( name = "pybind11_abseil", commit = "52f27398876a3177049977249e004770bd869e61", # 2024/01/11 + patches = ["//patches:pybind11_abseil.patch"], + patch_args = ["-p1"], remote = "https://github.com/pybind/pybind11_abseil.git", ) diff --git a/patches/pybind11_abseil.patch b/patches/pybind11_abseil.patch index b99adbda4c..37fc54e072 100644 --- a/patches/pybind11_abseil.patch +++ b/patches/pybind11_abseil.patch @@ -1,9 +1,17 @@ +diff --git a/.bazelignore b/.bazelignore +new file mode 100644 +index 0000000..378eac2 +--- /dev/null ++++ b/.bazelignore +@@ -0,0 +1 @@ ++build diff --git a/.gitignore b/.gitignore -index 2a7b42e..c96b037 100644 +index 2a7b42e..c2a37f0 100644 --- a/.gitignore +++ b/.gitignore -@@ -1,2 +1,3 @@ +@@ -1,2 +1,4 @@ build ++/bazel-* tmp_build +.*.swp diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -65,8 +73,87 @@ index 0000000..ffe4d38 + URL https://github.com/pybind/pybind11/archive/refs/heads/master.tar.gz) + +FetchContent_MakeAvailable(abseil-cpp pybind11) +diff --git a/pybind11_abseil/BUILD b/pybind11_abseil/BUILD +index 4cff8b7..33e614a 100644 +--- a/pybind11_abseil/BUILD ++++ b/pybind11_abseil/BUILD +@@ -25,43 +25,39 @@ pybind_library( + ], + ) + +-cc_library( ++pybind_library( + name = "ok_status_singleton_lib", + srcs = ["ok_status_singleton_lib.cc"], + hdrs = ["ok_status_singleton_lib.h"], + visibility = ["//visibility:public"], + deps = [ + "@com_google_absl//absl/status", +- "@local_config_python//:python_headers", # buildcleaner: keep + ], + ) + +-cc_library( ++pybind_library( + name = "ok_status_singleton_pyinit_google3", + srcs = ["ok_status_singleton_pyinit_google3.cc"], + visibility = ["//visibility:private"], + deps = [ + ":ok_status_singleton_lib", +- "@local_config_python//:python_headers", # buildcleaner: keep + ], + ) + +-cc_binary( +- name = "ok_status_singleton.so", ++pybind_extension( ++ name = "ok_status_singleton", + srcs = ["ok_status_singleton_py_extension_stub.cc"], +- linkshared = 1, + deps = [ + ":ok_status_singleton_pyinit_google3", +- "@local_config_python//:python_headers", # buildcleaner: keep + ], + ) + +-cc_library( ++pybind_library( + name = "no_throw_status", + hdrs = ["no_throw_status.h"], + ) + +-cc_library( ++pybind_library( + name = "status_not_ok_exception", + hdrs = ["status_not_ok_exception.h"], + deps = ["@com_google_absl//absl/status"], +@@ -104,7 +100,7 @@ pybind_library( + ], + ) + +-cc_library( ++pybind_library( + name = "init_from_tag", + hdrs = ["init_from_tag.h"], + visibility = ["//visibility:private"], +@@ -149,13 +145,11 @@ pybind_library( + ], + ) + +-cc_binary( +- name = "status.so", ++pybind_extension( ++ name = "status", + srcs = ["status_py_extension_stub.cc"], +- linkshared = 1, + deps = [ + ":status_pyinit_google3", +- "@local_config_python//:python_headers", # buildcleaner: keep + ], + ) + diff --git a/pybind11_abseil/CMakeLists.txt b/pybind11_abseil/CMakeLists.txt -index d1b7483..44da017 100644 +index d1b7483..96d462f 100644 --- a/pybind11_abseil/CMakeLists.txt +++ b/pybind11_abseil/CMakeLists.txt @@ -42,14 +42,19 @@ target_link_libraries(ok_status_singleton_pyinit_google3