Closed andreigh closed 10 months ago
All Windows CI fails with LINK : fatal error LNK1104: cannot open file 'python310_d.lib'
An idea would be to use find_package(PythonLibs 3.0)
like in Pytorch, which would fill in PYTHON_LIBRARIES:
optimized;C:/ProgramData/miniconda3/envs/pytorch/libs/python311.lib;debug;C:/Program Files/Python311/libs/python311_d.lib
and then, depending on CMAKE_BUILD_TYPE, use the specific library. But that's quite a big change.
So I am thinking reverting this PR and defining Py_DEBUG in Pytorch if _DEBUG is defined, so the workaround code doesn't get called.
PythonLibs has been deprecated since CMake 3.12, and has been removed (sort of) in CMake 3.27.
depending on CMAKE_BUILD_TYPE, use the specific library
This is complicated, due to multiconfiguation generators (like VSCode!) not using CMAKE_BUILD_TYPE.
Description
Compiling Pytorch in Debug mode on Windows gave:
LINK : fatal error LNK1104: cannot open file 'python311.lib'
After investigations I found that the files that include pybind11.h include Python.h with the _DEBUG symbol undef'd, thus triggering the #pragma lib("python311.lib"), which conflicted with the already linked (by CMake) python311_d.lib.
I removed the code changed by this PR, everything compiled successfully (only the Debug python lib is linked now).
This is with the latest VS2022, so I think the workaround is not needed anymore.
Suggested changelog entry: