You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
distutils has been deprecated from Python 3.10 and is scheduled to be removed from Python 3.12. The current use of distutils in library is in setup.py is to determine the MSVC compiler generator string for CMake. However, the method used to determine MSVC compiler doesn't work properly if there are multiple MSVC compilers installed. With MSVC2019 & MSVC2022 installed, the library thinks I don't have a valid MSVC compiler and fails to compile properly. I have came up with an updated method to use subprocess and vswhere to check for valid MSVC compiler. If I can, I would like to open a PR to add this change to the library.
Updated method to determine generator string for CMake
defdetermine_generator_args():
ifsys.platform=='win32':
pf_x86_path=pathlib.Path(os.getenv("ProgramFiles(x86)"))
vswhere_path=pf_x86_path.joinpath("Microsoft Visual Studio", "Installer", "vswhere.exe")
ifvswhere_path.is_file():
vswhere_process=subprocess.Popen(
[
str(vswhere_path),
"-products",
"*",
"-requires",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"-format",
"json",
"-nologo",
],
stdout=subprocess.PIPE,
)
compilers_data=json.loads(vswhere_process.communicate()[0])
vs_version=Nonevs_year=Noneforcompiler_dataincompilers_data:
compiler_version=int(compiler_data["catalog"]["productDisplayVersion"].split(".")[0])
compiler_year=int(compiler_data["catalog"]["productLineVersion"])
ifcompiler_yearin [2015, 2017, 2019]:
ifvs_yearisNoneorcompiler_year>vs_year:
vs_year=compiler_yearvs_version=compiler_versionassert(vs_versionandvs_year)
print('Using Visual Studio', vs_version, vs_year)
vs_version_gen_str="Visual Studio {} {}".format(vs_version, vs_year)
ifvs_year<=2017:
# For VS2017 and earlier, architecture goes at end of generator stringifis_64bit():
vs_version_gen_str+=" Win64"return ['-G', vs_version_gen_str]
# For VS2019 (and presumably later), architecture is passed via -A flagarch_str="x64"ifis_64bit() else"Win32"return ['-G', vs_version_gen_str, '-A', arch_str]
return []
The text was updated successfully, but these errors were encountered:
Thanks for taking the time to work on this and sorry for taking a long time to get back to you. I don't think we would accept this PR as it needs to work across multiple platforms, and it looks like your fix would only work for windows machines. It looks like setuptools is the better replacement for distutils.ccompiler. I'm closing this issue for now, but please let us know if you have other suggestions to improve this repo.
distutils has been deprecated from Python 3.10 and is scheduled to be removed from Python 3.12. The current use of distutils in library is in
setup.py
is to determine the MSVC compiler generator string for CMake. However, the method used to determine MSVC compiler doesn't work properly if there are multiple MSVC compilers installed. With MSVC2019 & MSVC2022 installed, the library thinks I don't have a valid MSVC compiler and fails to compile properly. I have came up with an updated method to use subprocess and vswhere to check for valid MSVC compiler. If I can, I would like to open a PR to add this change to the library.Updated method to determine generator string for CMake
The text was updated successfully, but these errors were encountered: