Skip to content

Commit 0afd14b

Browse files
committed
Set environment properly.
1 parent 0a62a0e commit 0afd14b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

setup.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@
8585
from distutils.command.build import build
8686
from distutils.command.install_data import install_data
8787
from distutils.core import Command
88+
from distutils.version import LooseVersion
8889

8990
bdist_msi = None # Do not build any MSI scripts
9091

9192
from distutils import log
92-
from distutils._msvccompiler import _find_exe
9393

9494
# some modules need a static CRT to avoid problems caused by them having a
9595
# manifest.
@@ -442,6 +442,10 @@ def initialize_options(self):
442442
self.debug = False
443443
self.build_temp = None
444444

445+
sdk_path = 'C:\\Program Files\\Microsoft SDKs\\Windows'
446+
windows_sdk = next(reversed(sorted(os.listdir(sdk_path), key=LooseVersion)))
447+
self.sdk_dir = os.path.join(sdk_path, windows_sdk)
448+
445449
def finalize_options(self):
446450
self.set_undefined_options('build', ('build_temp', 'build_temp'))
447451

@@ -478,9 +482,10 @@ def _build_scintilla(self):
478482

479483
cwd = os.getcwd()
480484
os.chdir(path)
481-
nmake = _find_exe("nmake.exe")
482485
try:
483-
cmd = [nmake, "/nologo", "/f", makefile] + makeargs
486+
setenv_cmd = [os.path.join(self.sdk_dir, "Bin", "SetEnv.cmd")]
487+
nmake_cmd = ["nmake.exe", "/nologo", "/f", makefile] + makeargs
488+
cmd = ["cmd.exe", "/c", '"{}" && "{}"'.format(' '.join(setenv_cmd), ' '.join(nmake_cmd))]
484489
self.spawn(cmd)
485490
finally:
486491
os.chdir(cwd)

0 commit comments

Comments
 (0)