|
77 | 77 | # We have special handling for _winreg so our setup3.py script can avoid |
78 | 78 | # using the 'imports' fixer and therefore start much faster... |
79 | 79 | import winreg |
| 80 | +import shutil |
80 | 81 |
|
81 | 82 | # The rest of our imports. |
82 | 83 | from setuptools import setup |
|
85 | 86 | from distutils.command.build import build |
86 | 87 | from distutils.command.install_data import install_data |
87 | 88 | from distutils.core import Command |
| 89 | +from distutils.version import LooseVersion |
88 | 90 |
|
89 | 91 | bdist_msi = None # Do not build any MSI scripts |
90 | 92 |
|
|
99 | 101 | from distutils.filelist import FileList |
100 | 102 | import distutils.util |
101 | 103 | import distutils.file_util |
| 104 | +import subprocess |
102 | 105 |
|
103 | 106 | # prevent the new in 3.5 suffix of "cpXX-win32" from being added. |
104 | 107 | # (adjusting both .cp35-win_amd64.pyd and .cp35-win32.pyd to .pyd) |
@@ -438,10 +441,18 @@ class build_scintilla(Command): |
438 | 441 | user_options = [] |
439 | 442 |
|
440 | 443 | def initialize_options(self): |
441 | | - pass |
| 444 | + self.debug = False |
| 445 | + self.build_temp = None |
| 446 | + self.build_lib = None |
| 447 | + |
| 448 | + sdk_path = 'C:\\Program Files\\Microsoft SDKs\\Windows' |
| 449 | + windows_sdk = next(reversed(sorted(os.listdir(sdk_path), key=LooseVersion))) |
| 450 | + self.sdk_dir = os.path.join(sdk_path, windows_sdk) |
442 | 451 |
|
443 | 452 | def finalize_options(self): |
444 | | - pass |
| 453 | + self.set_undefined_options('build', |
| 454 | + ('build_temp', 'build_temp'), |
| 455 | + ('build_lib', 'build_lib')) |
445 | 456 |
|
446 | 457 | def _build_scintilla(self): |
447 | 458 | path = 'pythonwin\\Scintilla' |
@@ -477,8 +488,12 @@ def _build_scintilla(self): |
477 | 488 | cwd = os.getcwd() |
478 | 489 | os.chdir(path) |
479 | 490 | try: |
480 | | - cmd = ["nmake.exe", "/nologo", "/f", makefile] + makeargs |
481 | | - self.spawn(cmd) |
| 491 | + import cmdvars |
| 492 | + env = cmdvars.get_vars(os.path.join(self.sdk_dir, "Bin", "SetEnv.cmd")) |
| 493 | + nmake = shutil.which('nmake.exe', path=env['path']) |
| 494 | + proc = subprocess.Popen([nmake, "/nologo", "/f", makefile] + makeargs, env=env) |
| 495 | + outs, errs = proc.communicate() |
| 496 | + print(outs, errs) |
482 | 497 | finally: |
483 | 498 | os.chdir(cwd) |
484 | 499 |
|
@@ -522,7 +537,7 @@ def _link_executable(self, *args, **kwargs): |
522 | 537 |
|
523 | 538 | def run(self): |
524 | 539 | build_ext.run(self) |
525 | | - # self.run_command('build_scintilla') |
| 540 | + self.run_command('build_scintilla') |
526 | 541 |
|
527 | 542 | def build_extensions(self): |
528 | 543 | # First, sanity-check the 'extensions' list |
@@ -569,8 +584,7 @@ def build_extensions(self): |
569 | 584 | print('Copying file to: ', dst) |
570 | 585 | self.copy_file(src, dst) |
571 | 586 |
|
572 | | - # self._copy_mfc() |
573 | | - # self._build_scintilla() |
| 587 | + # self._copy_mfc() |
574 | 588 | # Copy cpp lib files needed to create Python COM extensions |
575 | 589 | # print('Listing build directory:') |
576 | 590 | # self.list_files(os.path.dirname(self.build_temp)) |
@@ -1787,7 +1801,7 @@ def convert_optional_data_files(files): |
1787 | 1801 | package_dir=package_dir, |
1788 | 1802 | packages=packages, |
1789 | 1803 | py_modules=py_modules, |
1790 | | - setup_requires=['setuptools>=24.0'], |
| 1804 | + setup_requires=['setuptools>=24.0', 'cmdvars'], |
1791 | 1805 |
|
1792 | 1806 | data_files=[('', (os.path.join(gettempdir(), 'pywin32.version.txt'),))] + |
1793 | 1807 | convert_optional_data_files([ |
|
0 commit comments