Skip to content

Commit 3977e2d

Browse files
committed
Fix mod_per_interpreter_gil* output directory on Windows/MSVC
On Windows with MSVC (multi-configuration generators), CMake uses config-specific properties like LIBRARY_OUTPUT_DIRECTORY_DEBUG when set, otherwise falls back to LIBRARY_OUTPUT_DIRECTORY/<Config>/. The main test modules (pybind11_tests, etc.) correctly set both LIBRARY_OUTPUT_DIRECTORY and the config-specific variants (lines 517-528), so they output directly to tests/. However, the mod_per_interpreter_gil* modules only copied the base LIBRARY_OUTPUT_DIRECTORY property, causing them to be placed in tests/Debug/ instead of tests/. This mismatch caused test_import_in_subinterpreter_concurrently and related tests to fail with ModuleNotFoundError on Windows Python 3.14, because the test code sets sys.path based on pybind11_tests.__file__ (which is in tests/) but tries to import mod_per_interpreter_gil_with_singleton (which ended up in tests/Debug/). This bug was previously masked by @pytest.mark.xfail decorators on these tests. Now that the underlying "Duplicate C++ type registration" issue is fixed and the xfails are removed, this path issue surfaced. The fix mirrors the same pattern used for main test targets: also set LIBRARY_OUTPUT_DIRECTORY_<CONFIG> for each configuration type.
1 parent ed20cfc commit 3977e2d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,14 @@ if(NOT PYBIND11_CUDA_TESTS)
592592
foreach(mod IN LISTS PYBIND11_MULTIPLE_INTERPRETERS_TEST_MODULES)
593593
set_target_properties("${mod}" PROPERTIES LIBRARY_OUTPUT_DIRECTORY
594594
"${pybind11_tests_output_directory}")
595+
# Also set config-specific output directories for multi-configuration generators (MSVC)
596+
if(DEFINED CMAKE_CONFIGURATION_TYPES)
597+
foreach(config ${CMAKE_CONFIGURATION_TYPES})
598+
string(TOUPPER ${config} config)
599+
set_target_properties("${mod}" PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config}
600+
"${pybind11_tests_output_directory}")
601+
endforeach()
602+
endif()
595603
endforeach()
596604

597605
if(PYBIND11_TEST_SMART_HOLDER)

0 commit comments

Comments
 (0)