From 3b9b431da1c6c8b042de4add9f741ca88741943a Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Sat, 18 Jul 2026 20:23:50 +0200 Subject: [PATCH 01/13] CI: Build mrbind-pybind11 stubs as a thirdparty dependency --- CMakeLists.txt | 13 -- cmake/Modules/CompilerOptions.cmake | 29 ----- requirements/vcpkg-linux.txt | 1 + requirements/windows.txt | 1 + scripts/build_thirdparty.sh | 5 + source/MREmbeddedPython/CMakeLists.txt | 4 +- .../MREmbeddedPython/MREmbeddedPython.vcxproj | 7 +- source/MRPython/CMakeLists.txt | 20 ++- source/MRPython/MRPython.vcxproj | 16 ++- source/MRPython/MRPythonConfig.cmake | 1 + source/MRTest/MRTest.vcxproj | 3 - source/MeshLib.sln | 17 --- source/common.props | 9 +- source/mrmeshnumpy/mrmeshnumpy.vcxproj | 3 - source/mrviewerpy/mrviewerpy.vcxproj | 3 - thirdparty/CMakeLists.txt | 19 +-- thirdparty/mrbind-pybind11 | 2 +- thirdparty/pybind11nonlimitedapi.vcxproj | 115 ------------------ .../pybind11nonlimitedapi_stubs.vcxproj | 95 --------------- .../ports/mrbind-pybind11/portfile.cmake | 50 ++++++++ .../vcpkg/ports/mrbind-pybind11/vcpkg.json | 21 ++++ thirdparty/vcpkg/vcpkg.json | 1 + 22 files changed, 131 insertions(+), 304 deletions(-) delete mode 100644 thirdparty/pybind11nonlimitedapi.vcxproj delete mode 100644 thirdparty/pybind11nonlimitedapi_stubs.vcxproj create mode 100644 thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake create mode 100644 thirdparty/vcpkg/ports/mrbind-pybind11/vcpkg.json diff --git a/CMakeLists.txt b/CMakeLists.txt index df1c5103741f..b59276e094b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -295,19 +295,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/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..3d2f03a7bc9a 100644 --- a/source/MRPython/CMakeLists.txt +++ b/source/MRPython/CMakeLists.txt @@ -7,19 +7,29 @@ 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() +file( + COPY "${pybind11nonlimitedapi_SHIM_FILE}" + DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meshlib" +) +install( + FILES "${pybind11nonlimitedapi_SHIM_FILE}" + DESTINATION "${MR_PY_LIB_DIR}" +) + IF(APPLE) find_package(pybind11 REQUIRED) target_link_libraries(${PROJECT_NAME} PUBLIC pybind11::module) diff --git a/source/MRPython/MRPython.vcxproj b/source/MRPython/MRPython.vcxproj index 34c5787a053f..dabc8263c0ac 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,16 @@ true true true - ws2_32.lib;fmt.lib;spdlog.lib;%(AdditionalDependencies);$(PythonLibPath) + ws2_32.lib;fmt.lib;spdlog.lib;%(AdditionalDependencies);$(PythonLibPath);$(Pybind11StubsLibPath) + + + 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..20dd218a19ce 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 @@ -65,7 +72,7 @@ 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/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/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..8cc9e3fd8674 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -180,14 +180,17 @@ 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 "") + # Unify the pybind ABI across GCC and Clang. + 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 "") + ENDIF() add_subdirectory(./mrbind-pybind11) ENDIF() diff --git a/thirdparty/mrbind-pybind11 b/thirdparty/mrbind-pybind11 index b747f677ab30..96233b4098fd 160000 --- a/thirdparty/mrbind-pybind11 +++ b/thirdparty/mrbind-pybind11 @@ -1 +1 @@ -Subproject commit b747f677ab30ec62aca834c78383cd92c90e6b32 +Subproject commit 96233b4098fd1d68653aa5e26c8069b56f93ef7c 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..bcac0f60a080 --- /dev/null +++ b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake @@ -0,0 +1,50 @@ +# 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 96233b4098fd1d68653aa5e26c8069b56f93ef7c + SHA512 0 + 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") +else() + # Unify the pybind ABI across GCC and Clang. + list(APPEND EXTRA_OPTIONS + -DPYBIND11_NONLIMITEDAPI_COMPILER_TYPE_STRING=_meshlib + -DPYBIND11_NONLIMITEDAPI_BUILD_ABI_STRING=_meshlib + ) +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 + ${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..ac4272befcea --- /dev/null +++ b/thirdparty/vcpkg/ports/mrbind-pybind11/vcpkg.json @@ -0,0 +1,21 @@ +{ + "name": "mrbind-pybind11", + "version-string": "2.14.0-meshlib", + "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", From 1c4a79bfc17fe8c68374c0ecc11ed1a5f70eb9d2 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Sat, 18 Jul 2026 20:33:03 +0200 Subject: [PATCH 02/13] Update SHA512 --- thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake index bcac0f60a080..db8abde9072d 100644 --- a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake +++ b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake @@ -4,7 +4,7 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO MeshInspector/mrbind-pybind11 REF 96233b4098fd1d68653aa5e26c8069b56f93ef7c - SHA512 0 + SHA512 c87872140cfda09472b0893e15b6f54a81069ab4d6e7d5cd8c031aa274bf4e4206d4050c2480d71bbd8951bf6ca4b8217cbe3926ecd34890ca81287451526423 HEAD_REF non-limited-api ) From 458ee98dc830ccda91b4e7b4f1dceb0cd5c776f1 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Sat, 18 Jul 2026 22:00:22 +0200 Subject: [PATCH 03/13] Fix macOS build --- scripts/install_brew_requirements.sh | 2 -- source/MRPython/CMakeLists.txt | 2 -- thirdparty/mrbind-pybind11 | 2 +- thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake | 4 ++-- 4 files changed, 3 insertions(+), 7 deletions(-) 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/MRPython/CMakeLists.txt b/source/MRPython/CMakeLists.txt index 3d2f03a7bc9a..daecfea74de7 100644 --- a/source/MRPython/CMakeLists.txt +++ b/source/MRPython/CMakeLists.txt @@ -31,8 +31,6 @@ install( ) 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/thirdparty/mrbind-pybind11 b/thirdparty/mrbind-pybind11 index 96233b4098fd..9ca91973a7ce 160000 --- a/thirdparty/mrbind-pybind11 +++ b/thirdparty/mrbind-pybind11 @@ -1 +1 @@ -Subproject commit 96233b4098fd1d68653aa5e26c8069b56f93ef7c +Subproject commit 9ca91973a7ce12a17cd73bd9328b052291906d8d diff --git a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake index db8abde9072d..486a77fc6943 100644 --- a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake +++ b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake @@ -3,8 +3,8 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO MeshInspector/mrbind-pybind11 - REF 96233b4098fd1d68653aa5e26c8069b56f93ef7c - SHA512 c87872140cfda09472b0893e15b6f54a81069ab4d6e7d5cd8c031aa274bf4e4206d4050c2480d71bbd8951bf6ca4b8217cbe3926ecd34890ca81287451526423 + REF 9ca91973a7ce12a17cd73bd9328b052291906d8d + SHA512 f59f99533132691311751656b1e7f36730313afec535c2d0026bd7e09ef12c2b978c70b644ad522540479828ae4a17060a751c92ec9fa852f8722a4111031bd5 HEAD_REF non-limited-api ) From 62275a88e7b715499955cb5fc7ebf4c0d4f22a93 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Sat, 18 Jul 2026 22:37:11 +0200 Subject: [PATCH 04/13] Fix macOS build --- source/mrmeshnumpy/CMakeLists.txt | 1 + source/mrviewerpy/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) 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/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} From 5a63bbba7dcfe394ff7a99c383b7c5a514a679d9 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Sat, 18 Jul 2026 22:57:33 +0200 Subject: [PATCH 05/13] Fix Windows build --- source/MRPython/CMakeLists.txt | 8 ++++---- thirdparty/mrbind-pybind11 | 2 +- thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/MRPython/CMakeLists.txt b/source/MRPython/CMakeLists.txt index daecfea74de7..8b15a7b2bcdc 100644 --- a/source/MRPython/CMakeLists.txt +++ b/source/MRPython/CMakeLists.txt @@ -21,12 +21,12 @@ target_link_libraries(${PROJECT_NAME} 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() -file( - COPY "${pybind11nonlimitedapi_SHIM_FILE}" - DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meshlib" +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 "${pybind11nonlimitedapi_SHIM_FILE}" + FILES "$" DESTINATION "${MR_PY_LIB_DIR}" ) diff --git a/thirdparty/mrbind-pybind11 b/thirdparty/mrbind-pybind11 index 9ca91973a7ce..0053d7fd3175 160000 --- a/thirdparty/mrbind-pybind11 +++ b/thirdparty/mrbind-pybind11 @@ -1 +1 @@ -Subproject commit 9ca91973a7ce12a17cd73bd9328b052291906d8d +Subproject commit 0053d7fd31753f8113e1b2c74b27578fadba4bc9 diff --git a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake index 486a77fc6943..fdf4362152e6 100644 --- a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake +++ b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake @@ -3,8 +3,8 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO MeshInspector/mrbind-pybind11 - REF 9ca91973a7ce12a17cd73bd9328b052291906d8d - SHA512 f59f99533132691311751656b1e7f36730313afec535c2d0026bd7e09ef12c2b978c70b644ad522540479828ae4a17060a751c92ec9fa852f8722a4111031bd5 + REF 0053d7fd31753f8113e1b2c74b27578fadba4bc9 + SHA512 ee23818d4c29cde8166c43047e58135892d33c6c7cb50310d7402c312d1f07ab3e68a13d329356a7a945757d77cf96097ab5374cd1719393dfa6fbcf46530f9f HEAD_REF non-limited-api ) From 331453eb00676bc80592597a28e5ba1317d75f43 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Sun, 19 Jul 2026 09:11:31 +0200 Subject: [PATCH 06/13] Trigger rebuild From 3801fa00cc4bd570a89046cf9e6a16f842720ef1 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Tue, 21 Jul 2026 09:23:02 +0200 Subject: [PATCH 07/13] Fix macOS build --- CMakeLists.txt | 4 ++++ thirdparty/CMakeLists.txt | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b59276e094b7..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() diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 8cc9e3fd8674..791ef66ffb2b 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -190,6 +190,12 @@ IF(NOT MR_EMSCRIPTEN) 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() From cbc0951168b19011e4a2379124bb1ad5a3f3f69b Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Tue, 21 Jul 2026 09:46:03 +0200 Subject: [PATCH 08/13] WIP: Debug Windows unit test failure --- .github/workflows/pip-build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pip-build.yml b/.github/workflows/pip-build.yml index d2744bbafe80..46f54f068b4e 100644 --- a/.github/workflows/pip-build.yml +++ b/.github/workflows/pip-build.yml @@ -491,6 +491,12 @@ jobs: timeout-minutes: 10 run: source\x64\Release\MRTest.exe + - name: Print MRTest log + # The console output of a fast-exiting MRTest can be lost; the file sink keeps it. + if: failure() + shell: pwsh + run: Get-ChildItem "$env:TEMP\MeshViewer\Logs\MRLog_*.txt" | Sort-Object LastWriteTime | Select-Object -Last 1 | ForEach-Object { Write-Host "=== $($_.FullName) ==="; Get-Content $_ } + - name: Python Tests working-directory: source\x64\Release run: py -3 -u ..\..\..\scripts\run_python_test_script.py -multi-cmd From 5f1c358c5d545b1ff8e136f833779b5dce5f44d3 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Tue, 21 Jul 2026 10:54:23 +0200 Subject: [PATCH 09/13] WIP: Debug Windows unit test failure --- .github/workflows/pip-build.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pip-build.yml b/.github/workflows/pip-build.yml index 46f54f068b4e..83a72a14282d 100644 --- a/.github/workflows/pip-build.yml +++ b/.github/workflows/pip-build.yml @@ -491,11 +491,19 @@ jobs: timeout-minutes: 10 run: source\x64\Release\MRTest.exe - - name: Print MRTest log - # The console output of a fast-exiting MRTest can be lost; the file sink keeps it. + - name: Diagnose MRTest startup + # Rerun with file-redirected stdio: the console output of a fast-exiting process can be + # lost by the runner, while file redirection cannot. Prints the raw exit code too. if: failure() shell: pwsh - run: Get-ChildItem "$env:TEMP\MeshViewer\Logs\MRLog_*.txt" | Sort-Object LastWriteTime | Select-Object -Last 1 | ForEach-Object { Write-Host "=== $($_.FullName) ==="; Get-Content $_ } + run: | + $p = Start-Process -FilePath "source\x64\Release\MRTest.exe" -NoNewWindow -Wait -PassThru -RedirectStandardOutput mrtest-out.txt -RedirectStandardError mrtest-err.txt + "MRTest exit code: {0} (0x{0:X8})" -f $p.ExitCode + "--- stdout ---"; Get-Content mrtest-out.txt -ErrorAction SilentlyContinue + "--- stderr ---"; Get-Content mrtest-err.txt -ErrorAction SilentlyContinue + "--- meshlib dir ---"; Get-ChildItem source\x64\Release\meshlib | Select-Object Length, LastWriteTime, Name + "--- newest MRLog ---" + Get-ChildItem "$env:TEMP\MeshViewer\Logs\MRLog_*.txt" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime | Select-Object -Last 1 | ForEach-Object { Write-Host $_.FullName; Get-Content $_ } - name: Python Tests working-directory: source\x64\Release From ca938bc53478c0df575510d26d9c94b2f98398ed Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Tue, 21 Jul 2026 12:06:56 +0200 Subject: [PATCH 10/13] Fix Windows build --- source/MRPython/MRPython.vcxproj | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/MRPython/MRPython.vcxproj b/source/MRPython/MRPython.vcxproj index dabc8263c0ac..449cfaaa5266 100644 --- a/source/MRPython/MRPython.vcxproj +++ b/source/MRPython/MRPython.vcxproj @@ -126,8 +126,14 @@ + + + + - if not exist $(TargetDir)meshlib mkdir $(TargetDir)meshlib + copy $(PythonDllPath) $(TargetDir)python$(PythonVersion).dll + copy $(PythonStableDllPath) $(TargetDir)python3.dll + if not exist $(TargetDir)meshlib mkdir $(TargetDir)meshlib copy "$(Pybind11ShimDllPath)" $(TargetDir)meshlib\ From b4ab05a2b906994adb415f96d1d0041abe279729 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Wed, 22 Jul 2026 18:04:23 +0200 Subject: [PATCH 11/13] Revert debug changes --- .github/workflows/pip-build.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/pip-build.yml b/.github/workflows/pip-build.yml index 32e3414ab177..1d6ab0330719 100644 --- a/.github/workflows/pip-build.yml +++ b/.github/workflows/pip-build.yml @@ -491,20 +491,6 @@ jobs: timeout-minutes: 10 run: source\x64\Release\MRTest.exe - - name: Diagnose MRTest startup - # Rerun with file-redirected stdio: the console output of a fast-exiting process can be - # lost by the runner, while file redirection cannot. Prints the raw exit code too. - if: failure() - shell: pwsh - run: | - $p = Start-Process -FilePath "source\x64\Release\MRTest.exe" -NoNewWindow -Wait -PassThru -RedirectStandardOutput mrtest-out.txt -RedirectStandardError mrtest-err.txt - "MRTest exit code: {0} (0x{0:X8})" -f $p.ExitCode - "--- stdout ---"; Get-Content mrtest-out.txt -ErrorAction SilentlyContinue - "--- stderr ---"; Get-Content mrtest-err.txt -ErrorAction SilentlyContinue - "--- meshlib dir ---"; Get-ChildItem source\x64\Release\meshlib | Select-Object Length, LastWriteTime, Name - "--- newest MRLog ---" - Get-ChildItem "$env:TEMP\MeshViewer\Logs\MRLog_*.txt" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime | Select-Object -Last 1 | ForEach-Object { Write-Host $_.FullName; Get-Content $_ } - - name: Python Tests working-directory: source\x64\Release run: py -3 -u ..\..\..\scripts\run_python_test_script.py -multi-cmd From 093d52d220dcbcf5250b8fb45b8053ce69fba0c8 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Wed, 22 Jul 2026 18:09:30 +0200 Subject: [PATCH 12/13] Set compiler options unconditionally --- source/common.props | 4 ++-- thirdparty/CMakeLists.txt | 1 - thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake | 8 ++------ 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/source/common.props b/source/common.props index 20dd218a19ce..1702484936ed 100644 --- a/source/common.props +++ b/source/common.props @@ -66,9 +66,9 @@ /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) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 791ef66ffb2b..be51161a1b64 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -185,7 +185,6 @@ IF(NOT MR_EMSCRIPTEN) 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 "") - # Unify the pybind ABI across GCC and Clang. set(PYBIND11_NONLIMITEDAPI_COMPILER_TYPE_STRING "_meshlib" CACHE STRING "") set(PYBIND11_NONLIMITEDAPI_BUILD_ABI_STRING "_meshlib" CACHE STRING "") IF(APPLE) diff --git a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake index fdf4362152e6..5ac2f710f53c 100644 --- a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake +++ b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake @@ -12,12 +12,6 @@ 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") -else() - # Unify the pybind ABI across GCC and Clang. - list(APPEND EXTRA_OPTIONS - -DPYBIND11_NONLIMITEDAPI_COMPILER_TYPE_STRING=_meshlib - -DPYBIND11_NONLIMITEDAPI_BUILD_ABI_STRING=_meshlib - ) endif() vcpkg_cmake_configure( @@ -30,6 +24,8 @@ vcpkg_cmake_configure( -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} ) From 4d7fe241bd4d7eea4e43438fe2148c8a60a869a1 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Wed, 22 Jul 2026 18:17:23 +0200 Subject: [PATCH 13/13] Update mrbind-pybind11 --- thirdparty/mrbind-pybind11 | 2 +- thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake | 4 ++-- thirdparty/vcpkg/ports/mrbind-pybind11/vcpkg.json | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/thirdparty/mrbind-pybind11 b/thirdparty/mrbind-pybind11 index 0053d7fd3175..f11e5ce8140e 160000 --- a/thirdparty/mrbind-pybind11 +++ b/thirdparty/mrbind-pybind11 @@ -1 +1 @@ -Subproject commit 0053d7fd31753f8113e1b2c74b27578fadba4bc9 +Subproject commit f11e5ce8140ea8c7e8cf8156c18394aa73823024 diff --git a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake index 5ac2f710f53c..ce52fa04e698 100644 --- a/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake +++ b/thirdparty/vcpkg/ports/mrbind-pybind11/portfile.cmake @@ -3,8 +3,8 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO MeshInspector/mrbind-pybind11 - REF 0053d7fd31753f8113e1b2c74b27578fadba4bc9 - SHA512 ee23818d4c29cde8166c43047e58135892d33c6c7cb50310d7402c312d1f07ab3e68a13d329356a7a945757d77cf96097ab5374cd1719393dfa6fbcf46530f9f + REF f11e5ce8140ea8c7e8cf8156c18394aa73823024 + SHA512 71eb1ff48ba432683d3b8a14055718d1bc7ee796243f557c36e8c5715ad3920a978b0c6665423e054e70894aa603795819a1ec104da1f503f36b3e3d2648f564 HEAD_REF non-limited-api ) diff --git a/thirdparty/vcpkg/ports/mrbind-pybind11/vcpkg.json b/thirdparty/vcpkg/ports/mrbind-pybind11/vcpkg.json index ac4272befcea..da39076f4681 100644 --- a/thirdparty/vcpkg/ports/mrbind-pybind11/vcpkg.json +++ b/thirdparty/vcpkg/ports/mrbind-pybind11/vcpkg.json @@ -1,6 +1,7 @@ { "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",