diff --git a/CMakeLists.txt b/CMakeLists.txt
index df1c5103741f..f9c9cb80b022 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -170,6 +170,10 @@ IF(MESHLIB_PYTHON_SUPPORT AND NOT MR_EMSCRIPTEN)
ENDIF()
ENDIF()
+ IF(APPLE)
+ set(Python_ROOT_DIR "${HOMEBREW_PREFIX}/opt/python@${MESHLIB_PYTHON_VERSION}")
+ ENDIF()
+
IF(DEFINED MESHLIB_PYTHON_VERSION)
find_package(Python ${MESHLIB_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development)
ELSE()
@@ -295,19 +299,6 @@ IF(NOT MR_EMSCRIPTEN)
ENDIF()
ENDIF()
-IF(MESHLIB_PYTHON_SUPPORT)
- set(PYBIND11_NONLIMITEDAPI_PYTHON_MIN_VERSION_HEX 0x030800f0 CACHE STRING "") # Python 3.8
- set(PYBIND11_NONLIMITEDAPI_SUFFIX "${MESHLIB_PYBIND11_LIB_SUFFIX}" CACHE STRING "")
- set(PYBIND11_NONLIMITEDAPI_LIBRARY_OUTPUT_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meshlib" CACHE PATH "")
- set(PYBIND11_NONLIMITEDAPI_INSTALL_LIBDIR_STUBS "${MR_MAIN_LIB_DIR}" CACHE PATH "")
- set(PYBIND11_NONLIMITEDAPI_INSTALL_LIBDIR_SHIMS "${MR_PY_LIB_DIR}" CACHE PATH "")
- # We want to always build stubs here because we want to set `PYBIND11_COMPILER_TYPE`, `PYBIND11_BUILD_ABI` for them, and accessing them in `thirdparty/CMakeLists.txt` gets weird.
- # If not for that, we'd build them here only on Windows (because there we don't have a thirdparty build script).
- option(PYBIND11_NONLIMITEDAPI_BUILD_STUBS "" ON)
- option(PYBIND11_NONLIMITEDAPI_INSTALL_EXPORTS "" ON)
- add_subdirectory(${MESHLIB_THIRDPARTY_DIR}/mrbind-pybind11/source/non_limited_api ./meshlib)
-ENDIF()
-
IF(NOT MR_EMSCRIPTEN)
IF(MESHLIB_BUILD_MESHCONV)
add_subdirectory(${PROJECT_SOURCE_DIR}/meshconv ./meshconv)
diff --git a/cmake/Modules/CompilerOptions.cmake b/cmake/Modules/CompilerOptions.cmake
index 4a2c5a636e7f..1b369eb8e03c 100644
--- a/cmake/Modules/CompilerOptions.cmake
+++ b/cmake/Modules/CompilerOptions.cmake
@@ -125,35 +125,6 @@ IF(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
ENDIF()
-# This allows us to share bindings for C++ types across compilers (across GCC and Clang). Otherwise Pybind refuses
-# to share them because the compiler name and the ABI version number are different, even when there's no actual ABI incompatibility in practice.
-# We allow customizing those so that our clients can prevent their modules from talking to ours, e.g. to provide their own simplified bindings
-# for our classes, to avoid having our modules as dependencies.
-# Pass empty strings to those to avoid customizing them at all.
-set(MESHLIB_PYBIND11_COMPILER_TYPE_STRING "_meshlib" CACHE STRING "")
-set(MESHLIB_PYBIND11_BUILD_ABI_STRING "_meshlib" CACHE STRING "")
-IF(NOT "${MESHLIB_PYBIND11_COMPILER_TYPE_STRING}" STREQUAL "")
- add_compile_definitions(PYBIND11_COMPILER_TYPE=\"${MESHLIB_PYBIND11_COMPILER_TYPE_STRING}\")
-ENDIF()
-IF(NOT "${MESHLIB_PYBIND11_BUILD_ABI_STRING}" STREQUAL "")
- add_compile_definitions(PYBIND11_BUILD_ABI=\"${MESHLIB_PYBIND11_BUILD_ABI_STRING}\")
-ENDIF()
-
-# Things for our patched pybind: --- [
-
-# It's a good idea to have this match `PYTHON_MIN_VERSION` in `scripts/mrbind/generate.mk`.
-# Here `0x030800f0` corresponds to 3.8 (ignore the `f0` suffix at the end, it just means a release version as opposed to alpha/beta/etc).
-add_compile_definitions(Py_LIMITED_API=0x030800f0)
-
-# It's a good idea to have this match the value specified in `scripts/mrbind/generate.mk`. See that file for the explanation.
-add_compile_definitions(PYBIND11_INTERNALS_VERSION=5)
-
-# This affects the naming of our pybind shims.
-set(MESHLIB_PYBIND11_LIB_SUFFIX "meshlib" CACHE STRING "")
-add_compile_definitions(PYBIND11_NONLIMITEDAPI_LIB_SUFFIX_FOR_MODULE=\"${MESHLIB_PYBIND11_LIB_SUFFIX}\")
-
-# ] --- end things for our patched pybind
-
# Warn about ABI incompatibilities.
# GCC 12 fixed a bug, and this fix affects the ABI: https://github.com/gcc-mirror/gcc/commit/a37e8ce3b66325f0c6de55c80d50ac1664c3d0eb
# Because of this fix GCC 11 and older are incompatible with GCC 12+, and also with Clang that we use the build the Python bindings.
diff --git a/requirements/vcpkg-linux.txt b/requirements/vcpkg-linux.txt
index 1e7fcdd3d4cb..843d8f59f3c0 100644
--- a/requirements/vcpkg-linux.txt
+++ b/requirements/vcpkg-linux.txt
@@ -28,6 +28,7 @@ libe57format
libharu
libjpeg-turbo
libzip
+mrbind-pybind11
opencascade-minimal
openctm
openvdb
diff --git a/requirements/windows.txt b/requirements/windows.txt
index cb9fe9c345d0..35ebe5ca8e59 100644
--- a/requirements/windows.txt
+++ b/requirements/windows.txt
@@ -25,6 +25,7 @@ libe57format
libharu
libzip
mimalloc[override]
+mrbind-pybind11
opencascade-minimal
openctm
openvdb
diff --git a/scripts/build_thirdparty.sh b/scripts/build_thirdparty.sh
index 4fd3dcd54d6b..86d86ffac715 100755
--- a/scripts/build_thirdparty.sh
+++ b/scripts/build_thirdparty.sh
@@ -57,6 +57,11 @@ MR_CMAKE_OPTIONS="\
-D CMAKE_BUILD_TYPE=Release \
"
+# Which Python version the mrbind-pybind11 stubs and shim are built against.
+if [ -n "${MESHLIB_PYTHON_VERSION}" ] ; then
+ MR_CMAKE_OPTIONS="${MR_CMAKE_OPTIONS} -D PYBIND11_NONLIMITEDAPI_PYTHON_HEADERS_VERSION=${MESHLIB_PYTHON_VERSION}"
+fi
+
if [ "${MR_EMSCRIPTEN}" != "ON" ] ; then
CMAKE_C_COMPILER="${CMAKE_C_COMPILER:-${CC}}"
if [ -n "${CMAKE_C_COMPILER}" ] ; then
diff --git a/scripts/install_brew_requirements.sh b/scripts/install_brew_requirements.sh
index 7a7d31bfcf94..f178e2d5be1d 100755
--- a/scripts/install_brew_requirements.sh
+++ b/scripts/install_brew_requirements.sh
@@ -21,5 +21,3 @@ fi
brew untap aws/tap 2>/dev/null || true
brew install --quiet $(echo "$MESHLIB_BREW_REQUIREMENTS" | tr '\n' ' ')
-# FIXME: build w/o pybind11
-brew install --quiet pybind11
diff --git a/source/MREmbeddedPython/CMakeLists.txt b/source/MREmbeddedPython/CMakeLists.txt
index 5bffcf06e23c..75bf7ce4d293 100644
--- a/source/MREmbeddedPython/CMakeLists.txt
+++ b/source/MREmbeddedPython/CMakeLists.txt
@@ -7,10 +7,12 @@ add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})
# TODO: find Python independently
+find_package(pybind11nonlimitedapi REQUIRED HINTS "${MESHLIB_THIRDPARTY_ROOT_DIR}/lib/cmake/pybind11nonlimitedapi")
+
target_link_libraries(${PROJECT_NAME} PRIVATE
MRMesh
MRPython
- pybind11nonlimitedapi_stubs
+ pybind11nonlimitedapi::pybind11nonlimitedapi_stubs
${CMAKE_DL_LIBS}
)
diff --git a/source/MREmbeddedPython/MREmbeddedPython.vcxproj b/source/MREmbeddedPython/MREmbeddedPython.vcxproj
index 0b1b64cdcbca..ce6fec7b5723 100644
--- a/source/MREmbeddedPython/MREmbeddedPython.vcxproj
+++ b/source/MREmbeddedPython/MREmbeddedPython.vcxproj
@@ -16,9 +16,6 @@
-
- {cb6d82fb-e91d-4d62-b82e-be644244e30a}
-
{c7780500-ca0e-4f5f-8423-d7ab06078b14}
@@ -90,7 +87,7 @@
Console
true
- ws2_32.lib;fmtd.lib;spdlogd.lib;%(AdditionalDependencies);$(PythonLibPath)
+ ws2_32.lib;fmtd.lib;spdlogd.lib;%(AdditionalDependencies);$(PythonLibPath);$(Pybind11StubsLibPath)
@@ -120,7 +117,7 @@
true
true
true
- ws2_32.lib;fmt.lib;spdlog.lib;%(AdditionalDependencies);$(PythonLibPath)
+ ws2_32.lib;fmt.lib;spdlog.lib;%(AdditionalDependencies);$(PythonLibPath);$(Pybind11StubsLibPath)
diff --git a/source/MRPython/CMakeLists.txt b/source/MRPython/CMakeLists.txt
index f39b26de37d1..8b15a7b2bcdc 100644
--- a/source/MRPython/CMakeLists.txt
+++ b/source/MRPython/CMakeLists.txt
@@ -7,22 +7,30 @@ add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})
# TODO: find Python independently
-target_include_directories(${PROJECT_NAME}
- PUBLIC
- $
-)
+find_package(pybind11nonlimitedapi REQUIRED HINTS "${MESHLIB_THIRDPARTY_ROOT_DIR}/lib/cmake/pybind11nonlimitedapi")
target_link_libraries(${PROJECT_NAME}
PUBLIC
MRMesh
- pybind11nonlimitedapi_stubs
+ pybind11nonlimitedapi::pybind11nonlimitedapi_stubs
PRIVATE
${CMAKE_DL_LIBS}
)
+# Put the prebuilt shim next to the modules, where our patched pybind looks for it at runtime.
+if(NOT "${pybind11nonlimitedapi_SHIM_PYTHON_VERSION}" STREQUAL "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
+ message(FATAL_ERROR "The prebuilt pybind shim targets Python ${pybind11nonlimitedapi_SHIM_PYTHON_VERSION}, but this build uses ${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}. Rebuild the thirdparty against this Python version.")
+endif()
+add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meshlib"
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meshlib/"
+)
+install(
+ FILES "$"
+ DESTINATION "${MR_PY_LIB_DIR}"
+)
+
IF(APPLE)
- find_package(pybind11 REQUIRED)
- target_link_libraries(${PROJECT_NAME} PUBLIC pybind11::module)
target_link_options(${PROJECT_NAME} PRIVATE -undefined dynamic_lookup)
ENDIF()
diff --git a/source/MRPython/MRPython.vcxproj b/source/MRPython/MRPython.vcxproj
index 34c5787a053f..449cfaaa5266 100644
--- a/source/MRPython/MRPython.vcxproj
+++ b/source/MRPython/MRPython.vcxproj
@@ -11,9 +11,6 @@
-
- {cb6d82fb-e91d-4d62-b82e-be644244e30a}
-
{c7780500-ca0e-4f5f-8423-d7ab06078b14}
@@ -85,7 +82,7 @@
Console
true
- ws2_32.lib;fmtd.lib;spdlogd.lib;%(AdditionalDependencies);$(PythonLibPath)
+ ws2_32.lib;fmtd.lib;spdlogd.lib;%(AdditionalDependencies);$(PythonLibPath);$(Pybind11StubsLibPath)
@@ -95,10 +92,13 @@
+
copy $(PythonDllPath) $(TargetDir)python$(PythonVersion).dll
copy $(PythonStableDllPath) $(TargetDir)python3.dll
if exist "$(VcpkgCurrentInstalledDir)\bin\z.dll" copy "$(VcpkgCurrentInstalledDir)\bin\z.dll" "$(TargetDir)z.dll"
if exist "$(VcpkgCurrentInstalledDir)\bin\zlib1.dll" copy "$(VcpkgCurrentInstalledDir)\bin\zlib1.dll" "$(TargetDir)zlib1.dll"
+ if not exist $(TargetDir)meshlib mkdir $(TargetDir)meshlib
+ copy "$(Pybind11ShimDllPath)" $(TargetDir)meshlib\
@@ -121,10 +121,22 @@
true
true
true
- ws2_32.lib;fmt.lib;spdlog.lib;%(AdditionalDependencies);$(PythonLibPath)
+ ws2_32.lib;fmt.lib;spdlog.lib;%(AdditionalDependencies);$(PythonLibPath);$(Pybind11StubsLibPath)
+
+
+
+
+
+
+ copy $(PythonDllPath) $(TargetDir)python$(PythonVersion).dll
+ copy $(PythonStableDllPath) $(TargetDir)python3.dll
+ if not exist $(TargetDir)meshlib mkdir $(TargetDir)meshlib
+ copy "$(Pybind11ShimDllPath)" $(TargetDir)meshlib\
+
+
diff --git a/source/MRPython/MRPythonConfig.cmake b/source/MRPython/MRPythonConfig.cmake
index 1a34462cf027..1fd227d7b905 100644
--- a/source/MRPython/MRPythonConfig.cmake
+++ b/source/MRPython/MRPythonConfig.cmake
@@ -1,2 +1,3 @@
include(CMakeFindDependencyMacro)
+find_dependency(pybind11nonlimitedapi)
include("${CMAKE_CURRENT_LIST_DIR}/MRPythonTargets.cmake")
diff --git a/source/MRTest/MRTest.vcxproj b/source/MRTest/MRTest.vcxproj
index 63e89dc67c1d..0c0856a4634b 100644
--- a/source/MRTest/MRTest.vcxproj
+++ b/source/MRTest/MRTest.vcxproj
@@ -120,9 +120,6 @@
-
- {cb6d82fb-e91d-4d62-b82e-be644244e30a}
-
{e0202297-edb2-4cdc-9cd0-8921eff08da0}
diff --git a/source/MeshLib.sln b/source/MeshLib.sln
index 7ce7e45d86ed..5c960294c0a1 100644
--- a/source/MeshLib.sln
+++ b/source/MeshLib.sln
@@ -46,13 +46,6 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MRIOExtras", "MRIOExtras\MRIOExtras.vcxproj", "{99EB9674-ABBF-47CD-A8D5-EE122EB5DA0C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MRPython", "MRPython\MRPython.vcxproj", "{90BC6971-76CA-4ECD-92E0-585FE3BD6672}"
- ProjectSection(ProjectDependencies) = postProject
- {5612E480-6980-4242-9039-BE367F4ECBF0} = {5612E480-6980-4242-9039-BE367F4ECBF0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pybind11nonlimitedapi_stubs", "..\thirdparty\pybind11nonlimitedapi_stubs.vcxproj", "{CB6D82FB-E91D-4D62-B82E-BE644244E30A}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pybind11nonlimitedapi_meshlib", "..\thirdparty\pybind11nonlimitedapi.vcxproj", "{5612E480-6980-4242-9039-BE367F4ECBF0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MREmbeddedPython", "MREmbeddedPython\MREmbeddedPython.vcxproj", "{E0202297-EDB2-4CDC-9CD0-8921EFF08DA0}"
EndProject
@@ -128,14 +121,6 @@ Global
{90BC6971-76CA-4ECD-92E0-585FE3BD6672}.Debug|x64.Build.0 = Debug|x64
{90BC6971-76CA-4ECD-92E0-585FE3BD6672}.Release|x64.ActiveCfg = Release|x64
{90BC6971-76CA-4ECD-92E0-585FE3BD6672}.Release|x64.Build.0 = Release|x64
- {CB6D82FB-E91D-4D62-B82E-BE644244E30A}.Debug|x64.ActiveCfg = Debug|x64
- {CB6D82FB-E91D-4D62-B82E-BE644244E30A}.Debug|x64.Build.0 = Debug|x64
- {CB6D82FB-E91D-4D62-B82E-BE644244E30A}.Release|x64.ActiveCfg = Release|x64
- {CB6D82FB-E91D-4D62-B82E-BE644244E30A}.Release|x64.Build.0 = Release|x64
- {5612E480-6980-4242-9039-BE367F4ECBF0}.Debug|x64.ActiveCfg = Debug|x64
- {5612E480-6980-4242-9039-BE367F4ECBF0}.Debug|x64.Build.0 = Debug|x64
- {5612E480-6980-4242-9039-BE367F4ECBF0}.Release|x64.ActiveCfg = Release|x64
- {5612E480-6980-4242-9039-BE367F4ECBF0}.Release|x64.Build.0 = Release|x64
{E0202297-EDB2-4CDC-9CD0-8921EFF08DA0}.Debug|x64.ActiveCfg = Debug|x64
{E0202297-EDB2-4CDC-9CD0-8921EFF08DA0}.Debug|x64.Build.0 = Debug|x64
{E0202297-EDB2-4CDC-9CD0-8921EFF08DA0}.Release|x64.ActiveCfg = Release|x64
@@ -172,8 +157,6 @@ Global
{7CC4F0FE-ACE6-4441-9DD7-296066B6D69F} = {AE8B4895-7920-4AD3-B554-C858A08B1680}
{99EB9674-ABBF-47CD-A8D5-EE122EB5DA0C} = {AE8B4895-7920-4AD3-B554-C858A08B1680}
{90BC6971-76CA-4ECD-92E0-585FE3BD6672} = {AE8B4895-7920-4AD3-B554-C858A08B1680}
- {CB6D82FB-E91D-4D62-B82E-BE644244E30A} = {DAEF3759-BD96-475D-AA71-96ACC5279E43}
- {5612E480-6980-4242-9039-BE367F4ECBF0} = {DAEF3759-BD96-475D-AA71-96ACC5279E43}
{E0202297-EDB2-4CDC-9CD0-8921EFF08DA0} = {AE8B4895-7920-4AD3-B554-C858A08B1680}
{FFB8D063-FF1E-4F18-8479-249B36714EF7} = {E0BE85ED-C366-40EF-8BDE-70E1EDC8860F}
{C8250F26-E01D-4A63-98CD-68069D818080} = {AE8B4895-7920-4AD3-B554-C858A08B1680}
diff --git a/source/common.props b/source/common.props
index fed5c30e8a01..1702484936ed 100644
--- a/source/common.props
+++ b/source/common.props
@@ -49,6 +49,13 @@
$(VcpkgCurrentInstalledDir)\lib\python3.lib
$(VcpkgCurrentInstalledDir)\bin\python$(PythonVersion).dll
$(VcpkgCurrentInstalledDir)\bin\python3.dll
+
+ $(VcpkgCurrentInstalledDir)
+ $(VcpkgCurrentInstalledDir)\debug
+
+ $(VcpkgCurrentInstalledConfigDir)\lib\pybind11nonlimitedapi_stubs.lib
+ $(VcpkgCurrentInstalledConfigDir)\bin\pybind11nonlimitedapi_meshlib_3.$(PythonVersionMinor).dll
@@ -59,13 +66,13 @@
/bigobj /utf-8 %(AdditionalOptions)
-
+
- MR_PROJECT_NAME="$(MeshLibProjectName)";IMGUI_USER_CONFIG="imgui/MRCustomImGuiConfig.h";NOMINMAX;_CRT_SECURE_NO_DEPRECATE;ImDrawIdx=unsigned;SPDLOG_COMPILED_LIB;SPDLOG_SHARED_LIB;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING;_SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING;_SILENCE_CXX23_DENORM_DEPRECATION_WARNING;IMGUI_ENABLE_FREETYPE;IMGUI_DISABLE_OBSOLETE_FUNCTIONS;_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR;MRIOEXTRAS_OPENCASCADE_USE_XDE;PYBIND11_NONLIMITEDAPI_LIB_SUFFIX_FOR_MODULE="meshlib";Py_LIMITED_API=0x030800f0;%(PreprocessorDefinitions)
+ MR_PROJECT_NAME="$(MeshLibProjectName)";IMGUI_USER_CONFIG="imgui/MRCustomImGuiConfig.h";NOMINMAX;_CRT_SECURE_NO_DEPRECATE;ImDrawIdx=unsigned;SPDLOG_COMPILED_LIB;SPDLOG_SHARED_LIB;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING;_SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING;_SILENCE_CXX23_DENORM_DEPRECATION_WARNING;IMGUI_ENABLE_FREETYPE;IMGUI_DISABLE_OBSOLETE_FUNCTIONS;_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR;MRIOEXTRAS_OPENCASCADE_USE_XDE;PYBIND11_NONLIMITEDAPI_LIB_SUFFIX_FOR_MODULE="meshlib";Py_LIMITED_API=0x030800f0;PYBIND11_COMPILER_TYPE="_meshlib";PYBIND11_BUILD_ABI="_meshlib";%(PreprocessorDefinitions)
MR_PCH_USE_EXTRA_HEADERS;%(PreprocessorDefinitions)
- $(MeshLibSourceDir);$(PythonIncludePath);$(MeshLibDir)thirdparty\parallel-hashmap\;$(MeshLibDir)thirdparty\mrbind-pybind11\include\;$(VcpkgCurrentInstalledDir)\include\suitesparse\;$(VcpkgCurrentInstalledDir)\include\eigen3;$(MeshLibDir)thirdparty\imgui\;%(AdditionalIncludeDirectories)
+ $(MeshLibSourceDir);$(PythonIncludePath);$(MeshLibDir)thirdparty\parallel-hashmap\;$(VcpkgCurrentInstalledDir)\include\suitesparse\;$(VcpkgCurrentInstalledDir)\include\eigen3;$(MeshLibDir)thirdparty\imgui\;%(AdditionalIncludeDirectories)
Default
true
true
diff --git a/source/mrmeshnumpy/CMakeLists.txt b/source/mrmeshnumpy/CMakeLists.txt
index d48d52a0b500..477efef9b49a 100644
--- a/source/mrmeshnumpy/CMakeLists.txt
+++ b/source/mrmeshnumpy/CMakeLists.txt
@@ -23,6 +23,7 @@ ENDIF()
IF(APPLE)
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
+ target_link_options(${PROJECT_NAME} PRIVATE -undefined dynamic_lookup)
ENDIF()
target_link_libraries(${PROJECT_NAME}
diff --git a/source/mrmeshnumpy/mrmeshnumpy.vcxproj b/source/mrmeshnumpy/mrmeshnumpy.vcxproj
index e078f37e3a6f..318d9ed188f5 100644
--- a/source/mrmeshnumpy/mrmeshnumpy.vcxproj
+++ b/source/mrmeshnumpy/mrmeshnumpy.vcxproj
@@ -14,9 +14,6 @@
-
- {cb6d82fb-e91d-4d62-b82e-be644244e30a}
-
{c7780500-ca0e-4f5f-8423-d7ab06078b14}
diff --git a/source/mrviewerpy/CMakeLists.txt b/source/mrviewerpy/CMakeLists.txt
index 68171c965909..403faca7228e 100644
--- a/source/mrviewerpy/CMakeLists.txt
+++ b/source/mrviewerpy/CMakeLists.txt
@@ -23,6 +23,7 @@ ENDIF()
IF(APPLE)
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
+ target_link_options(${PROJECT_NAME} PRIVATE -undefined dynamic_lookup)
ENDIF()
target_link_libraries(${PROJECT_NAME}
diff --git a/source/mrviewerpy/mrviewerpy.vcxproj b/source/mrviewerpy/mrviewerpy.vcxproj
index 713f00e4db49..c2af2716d3b4 100644
--- a/source/mrviewerpy/mrviewerpy.vcxproj
+++ b/source/mrviewerpy/mrviewerpy.vcxproj
@@ -19,9 +19,6 @@
-
- {cb6d82fb-e91d-4d62-b82e-be644244e30a}
-
{c7780500-ca0e-4f5f-8423-d7ab06078b14}
diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt
index 55085c20f6ec..be51161a1b64 100644
--- a/thirdparty/CMakeLists.txt
+++ b/thirdparty/CMakeLists.txt
@@ -180,14 +180,22 @@ ENDIF()
IF(NOT MR_EMSCRIPTEN)
set(PYBIND11_INSTALL ON)
- # We want to build the stubs in our main `CMakeLists.txt` instead of here.
- # It seems to work fine either way, but I'm not comfortable not having the stubs see the customized cmake variables
- # that we set in our main `CMakeLists.txt`, such as those influencing the Pybind ABI strings.
- # Even though the stubs shouldn't call any Pybind functions right now, they still include the Pybind header.
- # Accidentally calling some inline Pybind function in it could have weird effects, I reckon.
- # Note that regardless of this setting, the python-version-specific shims always need to be built in our main `CMakeLists.txt`,
- # to see our configuration CMake variables.
- option(PYBIND11_NONLIMITEDAPI_BUILD_STUBS "" OFF)
+ option(PYBIND11_NONLIMITEDAPI_BUILD_STUBS "" ON)
+ option(PYBIND11_NONLIMITEDAPI_INSTALL_EXPORTS "" ON)
+ set(PYBIND11_NONLIMITEDAPI_SUFFIX "meshlib" CACHE STRING "")
+ set(PYBIND11_NONLIMITEDAPI_PYTHON_MIN_VERSION_HEX "0x030800f0" CACHE STRING "") # Python 3.8
+ set(PYBIND11_NONLIMITEDAPI_INTERNALS_VERSION "5" CACHE STRING "")
+ set(PYBIND11_NONLIMITEDAPI_COMPILER_TYPE_STRING "_meshlib" CACHE STRING "")
+ set(PYBIND11_NONLIMITEDAPI_BUILD_ABI_STRING "_meshlib" CACHE STRING "")
+ IF(APPLE)
+ set(PYBIND11_NONLIMITEDAPI_PYTHON_HEADERS_VERSION "3.10" CACHE STRING "")
+ execute_process(
+ COMMAND brew --prefix
+ OUTPUT_VARIABLE HOMEBREW_PREFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ set(Python_ROOT_DIR "${HOMEBREW_PREFIX}/opt/python@${PYBIND11_NONLIMITEDAPI_PYTHON_HEADERS_VERSION}")
+ ENDIF()
add_subdirectory(./mrbind-pybind11)
ENDIF()
diff --git a/thirdparty/mrbind-pybind11 b/thirdparty/mrbind-pybind11
index b747f677ab30..f11e5ce8140e 160000
--- a/thirdparty/mrbind-pybind11
+++ b/thirdparty/mrbind-pybind11
@@ -1 +1 @@
-Subproject commit b747f677ab30ec62aca834c78383cd92c90e6b32
+Subproject commit f11e5ce8140ea8c7e8cf8156c18394aa73823024
diff --git a/thirdparty/pybind11nonlimitedapi.vcxproj b/thirdparty/pybind11nonlimitedapi.vcxproj
deleted file mode 100644
index caf66d60d55a..000000000000
--- a/thirdparty/pybind11nonlimitedapi.vcxproj
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
-
-
-
-
- {cb6d82fb-e91d-4d62-b82e-be644244e30a}
-
-
-
- 16.0
- Win32Proj
- {5612E480-6980-4242-9039-BE367F4ECBF0}
- pybind11nonlimitedapi
- 10.0
- pybind11nonlimitedapi_meshlib
-
-
-
- DynamicLibrary
- true
- Unicode
-
-
- DynamicLibrary
- false
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- pybind11nonlimitedapi_meshlib_3.$(PythonVersionMinor)
-
-
-
-
- false
-
-
-
- Disabled
- true
- _DEBUG;_USRDLL;%(PreprocessorDefinitions)
- true
- NotUsing
- %(AdditionalIncludeDirectories);$(ProjectDir)mrbind-pybind11\include
- 4061;4250;4324;4365;4371;4388;4435;4514;4582;4583;4599;4605;4623;4625;4626;4668;4686;4710;4711;4820;4866;4868;5026;5027;5031;5039;5045;5104;5105;5219;5243;5246;5262;5264;26451;4190;4297;4457;4191;4548;%(DisableSpecificWarnings)
-
-
- Console
- true
- %(AdditionalDependencies)
- $(VcpkgCurrentInstalledDir)\lib;%(AdditionalLibraryDirectories)
-
-
-
-
- MaxSpeed
- true
- true
- true
- NDEBUG;%(PreprocessorDefinitions)
- true
- NotUsing
- %(AdditionalIncludeDirectories);$(ProjectDir)mrbind-pybind11\include
- 4061;4250;4324;4365;4371;4388;4435;4514;4582;4583;4599;4605;4623;4625;4626;4668;4686;4710;4711;4820;4866;4868;5026;5027;5031;5039;5045;5104;5105;5219;5243;5246;5262;5264;26451;4190;4297;4457;4191;4548;%(DisableSpecificWarnings)
-
-
- Console
- true
- true
- true
- %(AdditionalDependencies)
-
-
-
-
-
-
-
- if not exist $(TargetDir)meshlib mkdir $(TargetDir)meshlib
- copy $(TargetDir)$(TargetName).dll $(TargetDir)meshlib\$(TargetName).dll
-
-
-
- SyncCThrow
-
-
- SyncCThrow
-
-
-
\ No newline at end of file
diff --git a/thirdparty/pybind11nonlimitedapi_stubs.vcxproj b/thirdparty/pybind11nonlimitedapi_stubs.vcxproj
deleted file mode 100644
index 3937dcf14ad2..000000000000
--- a/thirdparty/pybind11nonlimitedapi_stubs.vcxproj
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
-
-
-
- 16.0
- Win32Proj
- {cb6d82fb-e91d-4d62-b82e-be644244e30a}
- pybind11nonlimitedapistubs
- 10.0
- pybind11nonlimitedapi_stubs
-
-
-
- DynamicLibrary
- true
- Unicode
-
-
- DynamicLibrary
- false
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- false
-
-
-
- Disabled
- true
- _DEBUG;_USRDLL;Py_LIMITED_API=0x030800f0;%(PreprocessorDefinitions)
- true
- NotUsing
- %(AdditionalIncludeDirectories);$(ProjectDir)mrbind-pybind11\include
- 4061;4250;4324;4365;4371;4388;4435;4514;4582;4583;4599;4605;4623;4625;4626;4668;4686;4710;4711;4820;4866;4868;5026;5027;5031;5039;5045;5104;5105;5219;5243;5246;5262;5264;26451;4190;%(DisableSpecificWarnings)
- SyncCThrow
-
-
- Console
- true
- %(AdditionalDependencies)
-
-
-
-
- MaxSpeed
- true
- true
- true
- NDEBUG;Py_LIMITED_API=0x030800f0;%(PreprocessorDefinitions)
- true
- NotUsing
- %(AdditionalIncludeDirectories);$(ProjectDir)mrbind-pybind11\include
- 4061;4250;4324;4365;4371;4388;4435;4514;4582;4583;4599;4605;4623;4625;4626;4668;4686;4710;4711;4820;4866;4868;5026;5027;5031;5039;5045;5104;5105;5219;5243;5246;5262;5264;26451;4190;%(DisableSpecificWarnings)
- SyncCThrow
-
-
- Console
- true
- true
- true
- %(AdditionalDependencies)
-
-
-
-
-
-
\ No newline at end of file
diff --git a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake
new file mode 100644
index 000000000000..ce52fa04e698
--- /dev/null
+++ b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake
@@ -0,0 +1,46 @@
+# REF must track the `thirdparty/mrbind-pybind11` submodule commit: when bumping the submodule,
+# update REF + SHA512 and bump "port-version" in vcpkg.json so the binary caches are invalidated.
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO MeshInspector/mrbind-pybind11
+ REF f11e5ce8140ea8c7e8cf8156c18394aa73823024
+ SHA512 71eb1ff48ba432683d3b8a14055718d1bc7ee796243f557c36e8c5715ad3920a978b0c6665423e054e70894aa603795819a1ec104da1f503f36b3e3d2648f564
+ HEAD_REF non-limited-api
+)
+
+set(EXTRA_OPTIONS "")
+if(VCPKG_TARGET_IS_WINDOWS)
+ # Pin the vcpkg Python; otherwise FindPython may pick a host installation.
+ list(APPEND EXTRA_OPTIONS "-DPython_EXECUTABLE=${CURRENT_INSTALLED_DIR}/tools/python3/python.exe")
+endif()
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ -DPYBIND11_INSTALL=ON
+ -DPYBIND11_TEST=OFF
+ -DPYBIND11_NONLIMITEDAPI_BUILD_STUBS=ON
+ -DPYBIND11_NONLIMITEDAPI_INSTALL_EXPORTS=ON
+ -DPYBIND11_NONLIMITEDAPI_SUFFIX=meshlib
+ -DPYBIND11_NONLIMITEDAPI_PYTHON_MIN_VERSION_HEX=0x030800f0
+ -DPYBIND11_NONLIMITEDAPI_INTERNALS_VERSION=5
+ -DPYBIND11_NONLIMITEDAPI_COMPILER_TYPE_STRING=_meshlib
+ -DPYBIND11_NONLIMITEDAPI_BUILD_ABI_STRING=_meshlib
+ ${EXTRA_OPTIONS}
+)
+
+vcpkg_cmake_install()
+
+vcpkg_cmake_config_fixup(
+ PACKAGE_NAME pybind11nonlimitedapi
+ CONFIG_PATH lib/cmake/pybind11nonlimitedapi
+)
+vcpkg_cmake_config_fixup(
+ PACKAGE_NAME pybind11
+ CONFIG_PATH share/cmake/pybind11
+)
+vcpkg_fixup_pkgconfig()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
diff --git a/thirdparty/vcpkg/ports/mrbind-pybind11/vcpkg.json b/thirdparty/vcpkg/ports/mrbind-pybind11/vcpkg.json
new file mode 100644
index 000000000000..da39076f4681
--- /dev/null
+++ b/thirdparty/vcpkg/ports/mrbind-pybind11/vcpkg.json
@@ -0,0 +1,22 @@
+{
+ "name": "mrbind-pybind11",
+ "version-string": "2.14.0-meshlib",
+ "port-version": 1,
+ "homepage": "https://github.com/MeshInspector/mrbind-pybind11",
+ "description": "pybind11 fork that builds stable-ABI Python modules",
+ "license": "BSD-3-Clause",
+ "dependencies": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ },
+ {
+ "name": "python3",
+ "platform": "windows"
+ }
+ ]
+}
diff --git a/thirdparty/vcpkg/vcpkg.json b/thirdparty/vcpkg/vcpkg.json
index 369b997712b1..ef02a326eeb3 100644
--- a/thirdparty/vcpkg/vcpkg.json
+++ b/thirdparty/vcpkg/vcpkg.json
@@ -33,6 +33,7 @@
"libharu",
"libjpeg-turbo",
"libzip",
+ "mrbind-pybind11",
"opencascade-minimal",
"openctm",
"openvdb",