fn default_lib_name_windows()

in include/pyo3/pyo3-build-config/src/impl_.rs [1712:1749]


fn default_lib_name_windows(
    version: PythonVersion,
    implementation: PythonImplementation,
    abi3: bool,
    mingw: bool,
    debug: bool,
    gil_disabled: bool,
) -> Result<String> {
    if debug && version < PythonVersion::PY310 {
        // CPython bug: linking against python3_d.dll raises error
        // https://github.com/python/cpython/issues/101614
        Ok(format!("python{}{}_d", version.major, version.minor))
    } else if abi3 && !(gil_disabled || implementation.is_pypy() || implementation.is_graalpy()) {
        if debug {
            Ok(WINDOWS_ABI3_DEBUG_LIB_NAME.to_owned())
        } else {
            Ok(WINDOWS_ABI3_LIB_NAME.to_owned())
        }
    } else if mingw {
        ensure!(
            !gil_disabled,
            "MinGW free-threaded builds are not currently tested or supported"
        );
        // https://packages.msys2.org/base/mingw-w64-python
        Ok(format!("python{}.{}", version.major, version.minor))
    } else if gil_disabled {
        ensure!(version >= PythonVersion::PY313, "Cannot compile C extensions for the free-threaded build on Python versions earlier than 3.13, found {}.{}", version.major, version.minor);
        if debug {
            Ok(format!("python{}{}t_d", version.major, version.minor))
        } else {
            Ok(format!("python{}{}t", version.major, version.minor))
        }
    } else if debug {
        Ok(format!("python{}{}_d", version.major, version.minor))
    } else {
        Ok(format!("python{}{}", version.major, version.minor))
    }
}