Skip to content

Commit 76df5f0

Browse files
authored
Merge pull request #30 from xoviat/scintilla
Actually build scintilla.
2 parents b64b923 + fe090c7 commit 76df5f0

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

setup.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
# We have special handling for _winreg so our setup3.py script can avoid
7878
# using the 'imports' fixer and therefore start much faster...
7979
import winreg
80+
import shutil
8081

8182
# The rest of our imports.
8283
from setuptools import setup
@@ -85,6 +86,7 @@
8586
from distutils.command.build import build
8687
from distutils.command.install_data import install_data
8788
from distutils.core import Command
89+
from distutils.version import LooseVersion
8890

8991
bdist_msi = None # Do not build any MSI scripts
9092

@@ -99,6 +101,7 @@
99101
from distutils.filelist import FileList
100102
import distutils.util
101103
import distutils.file_util
104+
import subprocess
102105

103106
# prevent the new in 3.5 suffix of "cpXX-win32" from being added.
104107
# (adjusting both .cp35-win_amd64.pyd and .cp35-win32.pyd to .pyd)
@@ -438,10 +441,18 @@ class build_scintilla(Command):
438441
user_options = []
439442

440443
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)
442451

443452
def finalize_options(self):
444-
pass
453+
self.set_undefined_options('build',
454+
('build_temp', 'build_temp'),
455+
('build_lib', 'build_lib'))
445456

446457
def _build_scintilla(self):
447458
path = 'pythonwin\\Scintilla'
@@ -477,8 +488,12 @@ def _build_scintilla(self):
477488
cwd = os.getcwd()
478489
os.chdir(path)
479490
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)
482497
finally:
483498
os.chdir(cwd)
484499

@@ -522,7 +537,7 @@ def _link_executable(self, *args, **kwargs):
522537

523538
def run(self):
524539
build_ext.run(self)
525-
# self.run_command('build_scintilla')
540+
self.run_command('build_scintilla')
526541

527542
def build_extensions(self):
528543
# First, sanity-check the 'extensions' list
@@ -569,8 +584,7 @@ def build_extensions(self):
569584
print('Copying file to: ', dst)
570585
self.copy_file(src, dst)
571586

572-
# self._copy_mfc()
573-
# self._build_scintilla()
587+
# self._copy_mfc()
574588
# Copy cpp lib files needed to create Python COM extensions
575589
# print('Listing build directory:')
576590
# self.list_files(os.path.dirname(self.build_temp))
@@ -1787,7 +1801,7 @@ def convert_optional_data_files(files):
17871801
package_dir=package_dir,
17881802
packages=packages,
17891803
py_modules=py_modules,
1790-
setup_requires=['setuptools>=24.0'],
1804+
setup_requires=['setuptools>=24.0', 'cmdvars'],
17911805

17921806
data_files=[('', (os.path.join(gettempdir(), 'pywin32.version.txt'),))] +
17931807
convert_optional_data_files([

tests/requirements-tools.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ pycmd # Contains 'py.cleanup' that removes all .pyc files and similar.
2424
codecov
2525
pytest-cov
2626
packaging
27+
cmdvars

0 commit comments

Comments
 (0)