Build error in Windows in debug mode due to python312_d.lib

I’ve been building Slicer for a long while using the same scripts. I’ve updated to the latest Slicer main version (from a version maybe a few weeks ago), started a clean build from scratch (removed all build folders) and this latest version does not build due to python312_d.lib is not found when linking qSlicerBaseQTCore.

165>------ Build started: Project: qSlicerBaseQTCore, Configuration: Debug x64 ------
165>LINK : fatal error LNK1104: cannot open file 'python312_d.lib'

Has anyone encountered this error?

@jcfr @jamesobutler

The only mentions of python312_d.lib in any files in all build folders:

In Python-3.12.10/PC/pyconfig.h, python-build/bin/Release/PC/pyconfig.h, and python-install\include\pyconfig.h:

...
/* For an MSVC DLL, we can nominate the .lib files used by extensions */
#ifdef MS_COREDLL
#       if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
                /* not building the core - must be an ext */
#               if defined(_MSC_VER)
                        /* So MSVC users need not specify the .lib
                        file in their Makefile (other compilers are
                        generally taken care of by distutils.) */
#                       if defined(_DEBUG)
#                               pragma comment(lib,"python312_d.lib")
#                       elif defined(Py_LIMITED_API)
#                               pragma comment(lib,"python3.lib")
#                       else
#                               pragma comment(lib,"python312.lib")
#                       endif /* _DEBUG */
#               endif /* _MSC_VER */
#       endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */
...

In Slicer-build\Base\QTCore\qSlicerBaseQTCore.dir\Debug\qSlicerCoreApplication.obj:

/DEFAULTLIB:"python312_d.lib"

Modifying the pyconfig.h files from:

#                               pragma comment(lib,"python312_d.lib")

to

#                               pragma comment(lib,"python312.lib")

resolves the build problem, so something may have changed in how pyconfig.h is included or in MS_COREDLL, Py_BUILD_CORE, Py_BUILD_CORE_BUILTIN, _MSC_VER, or _DEBUG defines.