* get rid of ${Python_LIBRARIES} (ed unavailable on manylinux)
note: module shouldn't link against libpython.so but only depends on python.h
since it will be dynamic loaded in the python process which already have
the python symbols loaded...
85 lines
3.2 KiB
Diff
85 lines
3.2 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index e936f66..eaac571 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -21,7 +21,7 @@ option(BUILD_TESTS "Build tests." OFF)
|
|
# ============================================================================
|
|
# Find Python
|
|
|
|
-find_package(Python COMPONENTS Interpreter Development)
|
|
+find_package(Python3 COMPONENTS Interpreter Development.Module)
|
|
|
|
# ============================================================================
|
|
# Build dependencies
|
|
@@ -47,8 +47,10 @@ pybind11_add_module(
|
|
pybind11_protobuf/proto_utils.h)
|
|
|
|
target_link_libraries(
|
|
- pybind11_proto_utils PRIVATE absl::strings protobuf::libprotobuf
|
|
- ${Python_LIBRARIES})
|
|
+ pybind11_proto_utils PRIVATE
|
|
+ absl::strings
|
|
+ protobuf::libprotobuf
|
|
+ Python3::Module)
|
|
|
|
target_include_directories(
|
|
pybind11_proto_utils PRIVATE ${PROJECT_SOURCE_DIR} ${protobuf_INCLUDE_DIRS}
|
|
@@ -57,7 +59,7 @@ target_include_directories(
|
|
# ============================================================================
|
|
# pybind11_native_proto_caster shared library
|
|
add_library(
|
|
- pybind11_native_proto_caster SHARED
|
|
+ pybind11_native_proto_caster STATIC
|
|
# bazel: pybind_library: native_proto_caster
|
|
pybind11_protobuf/native_proto_caster.h
|
|
# bazel: pybind_library: enum_type_caster
|
|
@@ -79,10 +81,12 @@ target_link_libraries(
|
|
absl::optional
|
|
protobuf::libprotobuf
|
|
pybind11::pybind11
|
|
- ${Python_LIBRARIES})
|
|
+ Python3::Module)
|
|
|
|
target_include_directories(
|
|
pybind11_native_proto_caster
|
|
+ PUBLIC
|
|
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
|
PRIVATE ${PROJECT_SOURCE_DIR} ${protobuf_INCLUDE_DIRS} ${protobuf_SOURCE_DIR}
|
|
${pybind11_INCLUDE_DIRS})
|
|
|
|
@@ -109,7 +113,7 @@ target_link_libraries(
|
|
absl::optional
|
|
protobuf::libprotobuf
|
|
pybind11::pybind11
|
|
- ${Python_LIBRARIES})
|
|
+ Python3::Module)
|
|
|
|
target_include_directories(
|
|
pybind11_wrapped_proto_caster
|
|
diff --git a/pybind11_protobuf/proto_cast_util.cc b/pybind11_protobuf/proto_cast_util.cc
|
|
index 06bde44..1cc6a30 100644
|
|
--- a/pybind11_protobuf/proto_cast_util.cc
|
|
+++ b/pybind11_protobuf/proto_cast_util.cc
|
|
@@ -599,13 +599,14 @@ absl::optional<std::string> PyProtoDescriptorName(py::handle py_proto) {
|
|
|
|
bool PyProtoIsCompatible(py::handle py_proto, const Descriptor* descriptor) {
|
|
assert(PyGILState_Check());
|
|
- if (descriptor->file()->pool() != DescriptorPool::generated_pool()) {
|
|
- /// This indicates that the C++ descriptor does not come from the C++
|
|
- /// DescriptorPool. This may happen if the C++ code has the same proto
|
|
- /// in different descriptor pools, perhaps from different shared objects,
|
|
- /// and could be result in undefined behavior.
|
|
- return false;
|
|
- }
|
|
+ // if (descriptor->file()->pool() != DescriptorPool::generated_pool()) {
|
|
+ // /// This indicates that the C++ descriptor does not come from the C++
|
|
+ // /// DescriptorPool. This may happen if the C++ code has the same proto
|
|
+ // /// in different descriptor pools, perhaps from different shared objects,
|
|
+ // /// and could be result in undefined behavior.
|
|
+ // std::cout << " * Different";
|
|
+ // return false;
|
|
+ // }
|
|
|
|
auto py_descriptor = ResolveAttrs(py_proto, {"DESCRIPTOR"});
|
|
if (!py_descriptor) {
|