From b52884ae5417fd2f857007ae1c74d4f753591d36 Mon Sep 17 00:00:00 2001 From: kxrob Date: Sun, 21 Aug 2022 20:57:43 +0200 Subject: [PATCH] Unfreeze setuptools version again, workaround after freeze in a22bd62. The workaround should become obsolete (silently) when distutils / setuptools is fixed midterm. Fix in Scintilla/makefile_pythonwin: nested nmake execution did not return errors (return code) --- .github/workflows/main.yml | 7 ++----- Pythonwin/Scintilla/makefile_pythonwin | 4 ++-- setup.py | 26 ++++++++++++++++++++------ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bbe343afe7..e7a85d2a8d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,10 +28,7 @@ jobs: run: | python --version pip --version - # XXX With setuptools 63.4.3 .. 64.0.0 the scintilla nmake won't compile ( - # setuptools.msvc._msvc14_get_vc_env() won't get the VC\INCLUDE into os.environ) - # Lets see if this will be fixed again in higher versions - pip install --upgrade setuptools<=63.2.0 wheel + pip install --upgrade setuptools wheel - name: Build and install run: | @@ -83,7 +80,7 @@ jobs: run: | python --version pip --version - pip install --upgrade setuptools<=63.2.0 wheel + pip install --upgrade setuptools wheel - name: Obtain ARM64 library files run: | diff --git a/Pythonwin/Scintilla/makefile_pythonwin b/Pythonwin/Scintilla/makefile_pythonwin index baf2889570..7897e76e33 100644 --- a/Pythonwin/Scintilla/makefile_pythonwin +++ b/Pythonwin/Scintilla/makefile_pythonwin @@ -32,7 +32,7 @@ all: ..\pywin\scintilla\scintillacon.py Scintilla clean: - cd win32 && $(MAKE) /$(MAKEFLAGS) -f scintilla.mak DIR_BIN=$(SUB_DIR_BIN) DIR_O=$(SUB_DIR_O) clean & cd.. + cd win32 && $(MAKE) /$(MAKEFLAGS) -f scintilla.mak DIR_BIN=$(SUB_DIR_BIN) DIR_O=$(SUB_DIR_O) clean && cd .. Scintilla: @if not exist $(DIR_O) md $(DIR_O) @@ -42,7 +42,7 @@ Scintilla: @set LINK=$(LINK) /nologo where cl set INCLUDE - @cd win32 && $(MAKE) /$(MAKEFLAGS) /f scintilla.mak DIR_BIN=$(SUB_DIR_BIN) DIR_O=$(SUB_DIR_O) LEXCOMPONENT=$(SCINTILLA_DLL) COMPONENT=dummy $(SCINTILLA_DLL) & cd.. + @cd win32 && $(MAKE) /$(MAKEFLAGS) /f scintilla.mak DIR_BIN=$(SUB_DIR_BIN) DIR_O=$(SUB_DIR_O) LEXCOMPONENT=$(SCINTILLA_DLL) COMPONENT=dummy $(SCINTILLA_DLL) && cd .. ..\pywin\scintilla\scintillacon.py: Include\Scintilla.h Include\SciLexer.h @if not exist $(DIR_PYTHON)\tools\scripts\h2py.py echo ***** Can't find h2py.py in '$(DIR_PYTHON)\tools\scripts - please pass DIR_PYTHON to this script ******* diff --git a/setup.py b/setup.py index d88315c773..d9bb6dec7f 100644 --- a/setup.py +++ b/setup.py @@ -598,6 +598,7 @@ def _why_cant_build_extension(self, ext): look_dirs = common_dirs + ext.library_dirs found = self.compiler.find_library_file(look_dirs, lib, self.debug) if not found: + print("-- LIB NOT FOUND:", lib, look_dirs) log.debug("Looked for %s in %s", lib, look_dirs) return "No library '%s'" % lib self.found_libraries[lib.lower()] = found @@ -654,14 +655,9 @@ def _build_scintilla(self): cwd = os.getcwd() old_env = os.environ.copy() - os.chdir(path) - print("-- _build_scintilla INCLUDE old:", os.environ.get("INCLUDE")) - if not self.compiler.initialized: - print("-- _build_scintilla compiler.initialize()") - self.compiler.initialize() os.environ["INCLUDE"] = os.pathsep.join(self.compiler.include_dirs) os.environ["LIB"] = os.pathsep.join(self.compiler.library_dirs) - print("-- _build_scintilla INCLUDE new:", os.environ.get("INCLUDE")) + os.chdir(path) try: cmd = [nmake, "/nologo", "/f", makefile] + makeargs self.compiler.spawn(cmd) @@ -689,6 +685,24 @@ def build_extensions(self): if not self.compiler.initialized: self.compiler.initialize() + # XXX this distutils class var peek hack should become obsolete + # (silently) when https://github.com/pypa/distutils/pull/172 is + # resolved. + # _why_cant_build_extension() and _build_scintilla() at least need + # complete VC+SDK inspectable inc / lib dirs. + classincs = getattr(self.compiler.__class__, "include_dirs", []) + if classincs: + log.warn("distutils hack to expose complete inc/lib dirs") + print("-- orig compiler.include_dirs:", self.compiler.include_dirs) + print("-- orig compiler.library_dirs:", self.compiler.library_dirs) + self.compiler.include_dirs += classincs + self.compiler.__class__.include_dirs = [] + classlibs = getattr(self.compiler.__class__, "library_dirs", []) + self.compiler.library_dirs += classlibs + self.compiler.__class__.library_dirs = [] + else: + print("-- FIX ME ! distutils may expose complete inc/lib dirs again") + self._fixup_sdk_dirs() # Here we hack a "pywin32" directory (one of 'win32', 'win32com',