How to Force specific MSVC Version in Python Setuptools with Ninja?

33 views Asked by At

I try to compile my c++ / CUDA Code for a python/PyTorch package with conda bdsist. When running my setup.py I always get the error that only Visual Studio 2015-2019 is compatible. I do have Visual Studio 2017 and 2022 installed. In my environment variables I removed all links to VS 2022 and changed them to 2017.

However ninja uses the MSVC from 2022 as a compiler.

I tried to manipulate the following Environment variables:

CUDA_PATH
CUDA_PATH_V10_2
DEVENVDIR
EXTENSIONSDKDIR
EXTERNAL_INCLUDE
IFCPATH
INCLUDE
LIB
LIBPATH
OS
PATH
PLAT
PLATFORM
UNIVERSALCRTSDKDIR
VCIDEINSTALLDIR
VCINSTALLDIR
VCPKG_ROOT
VCTOOLSINSTALLDIR
VCTOOLSREDISTDIR
VCTOOLSVERSION
VISUALSTUDIOVERSION
VS140COMNTOOLS
VS170COMNTOOLS
VSCMD_ARG_APP_PLAT
VSCMD_ARG_HOST_ARCH
VSCMD_ARG_TGT_ARCH
VSCMD_VER
VSINSTALLDIR
WINDIR
WINDOWSLIBPATH
WINDOWSSDKBINPATH
WINDOWSSDKDIR
WINDOWSSDKLIBVERSION
WINDOWSSDKVERBINPATH
WINDOWSSDKVERSION
__VSCMD_PREINIT_PATH
PY_VCRUNTIME_REDIST

However distutils._msvccompiler._get_vc_env() seems to overwrite the environment variables. While trying to find a Visual studio Version _msvccompiler looks for the vswhere.exe and I guess the vswhere.exe returns the Visual Studio 2022 PATHs.

Is there a possibility to force ninja to use Visual Studio 2017s cl?

0

There are 0 answers