Skip to content

Commit 65db6ad

Browse files
committed
Fix Windows CI failures: MSVC-specific settings and debug prelude
- Remove /pthread from Windows CMAKE_CXX_FLAGS (MSVC doesn't support it) - Replace with /O2 /EHsc for proper MSVC optimization and exception handling - Add CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>DLL - Add CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE for static lib placement - Add CIBW_TEST_COMMAND_WINDOWS with debug prelude to diagnose import issues - Use backslashes in pytest path on Windows (pytest {project}\\tests -vv) Debug prelude will print: - Python version and platform - python_prtree installation directory - Package contents (to verify PRTree*.pyd exists) - Import success/failure with full traceback These changes address Windows-specific packaging issues while maintaining compatibility with Linux/macOS builds. All 123 tests pass locally.
1 parent ff48f6a commit 65db6ad

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.github/workflows/cibuildwheel.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ jobs:
225225
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
226226
CIBW_BEFORE_BUILD: pip install pybind11
227227
CIBW_TEST_COMMAND: pytest {project}/tests -vv
228+
CIBW_TEST_COMMAND_WINDOWS: >-
229+
python -c "import sys, importlib.util, pathlib, traceback; print('sys.version:', sys.version); print('sys.platform:', sys.platform); exec('try:\n import python_prtree\n p = pathlib.Path(python_prtree.__file__).parent\n print(\"python_prtree dir:\", p)\n print(\"contents:\", sorted(x.name for x in p.iterdir()))\n print(\"find_spec(PRTree):\", importlib.util.find_spec(\"python_prtree.PRTree\"))\n from python_prtree import PRTree3D\n print(\"import PRTree3D ok\")\nexcept Exception as e:\n print(\"IMPORT FAILED:\", repr(e))\n traceback.print_exc()\n raise')" &&
230+
pytest {project}\\tests -vv
228231
CIBW_TEST_REQUIRES: pytest numpy
229232
CIBW_BUILD_VERBOSITY: 1
230233
CIBW_ARCHS: ${{ matrix.arch }}

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.5)
22

33
if(WIN32)
4-
set(CMAKE_CXX_FLAGS "/O3 /pthread")
4+
set(CMAKE_CXX_FLAGS "/O2 /EHsc")
55
elseif(APPLE)
66
set(CMAKE_CXX_FLAGS "-O3 -pthread")
77
else()

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def build_extension(self, ext):
6767
if platform.system() == "Windows":
6868
cmake_args += [
6969
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir),
70-
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir)
70+
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir),
71+
"-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir),
72+
"-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
7173
]
7274
if sys.maxsize > 2**32:
7375
cmake_args += ["-A", "x64"]

0 commit comments

Comments
 (0)