Skip to content

Commit

Permalink
fix(build): Fixed Windows build with recent setuptools versions
Browse files Browse the repository at this point in the history
  • Loading branch information
flozz committed Nov 25, 2024
1 parent 1d86e98 commit a523998
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,33 @@
def _find_msbuild(plat_spec="x64"):
from setuptools import msvc

vc_env = msvc.msvc14_get_vc_env(plat_spec)
if "vsinstalldir" not in vc_env:
raise Exception("Unable to find any Visual Studio installation")
return os.path.join(
vc_env["vsinstalldir"], "MSBuild", "Current", "Bin", "MSBuild.exe"
)
if hasattr(msvc, "msvc14_get_vc_env"):
vc_env = msvc.msvc14_get_vc_env(plat_spec)
if "vsinstalldir" in vc_env:
msbuild_path = os.path.join(
vc_env["vsinstalldir"],
"MSBuild",
"Current",
"Bin",
"MSBuild.exe",
)
if os.path.isfile(msbuild_path):
return msbuild_path

for path in msvc.EnvironmentInfo(plat_spec).VCTools:
if "\\VC\\" not in path:
continue
msbuild_path = os.path.join(
path[: path.index("\\VC\\")],
"MSBuild",
"Current",
"Bin",
"MSBuild.exe",
)
if os.path.isfile(msbuild_path):
return msbuild_path

raise Exception("Unable to find any Visual Studio installation")


class CustomBuildExt(build_ext):
Expand Down

0 comments on commit a523998

Please sign in to comment.