From e055b3b831a3c8e2f24d047b5edbe326a0cac7bf Mon Sep 17 00:00:00 2001 From: kxrob Date: Sun, 21 Aug 2022 20:57:43 +0200 Subject: [PATCH] Remove obsolete _fixup_sdk_dirs() mechanism in setup.py Newer distutils / setuptools versions already use and expose the MSVC & SDK dirs - taken from vcvarsall.bat . We need and should not use a different mechanism anymore. (Include & lib dirs of 2 different SDK kits were seen on compiler command lines at the same time on github CI) --- setup.py | 86 -------------------------------------------------------- 1 file changed, 86 deletions(-) diff --git a/setup.py b/setup.py index 1d5fa30cf3..d1023eb5d2 100644 --- a/setup.py +++ b/setup.py @@ -86,73 +86,6 @@ # dll_base_address later in this file... dll_base_address = 0x1E200000 -# We need to know the platform SDK dir before we can list the extensions. -def find_platform_sdk_dir(): - # The user might have their current environment setup for the - # SDK, in which case "MSSDK_INCLUDE" and "MSSDK_LIB" vars must be set. - if "MSSDK_INCLUDE" in os.environ and "MSSDK_LIB" in os.environ: - print("Using SDK as specified in the environment") - return { - "include": os.environ["MSSDK_INCLUDE"].split(os.path.pathsep), - "lib": os.environ["MSSDK_LIB"].split(os.path.pathsep), - } - - # Find the win 10 SDKs installed. - installedVersions = [] - try: - key = winreg.OpenKey( - winreg.HKEY_LOCAL_MACHINE, - r"SOFTWARE\Microsoft\Windows Kits\Installed Roots", - 0, - winreg.KEY_READ | winreg.KEY_WOW64_32KEY, - ) - installRoot = winreg.QueryValueEx(key, "KitsRoot10")[0] - keyNo = 0 - while 1: - try: - installedVersions.append(winreg.EnumKey(key, keyNo)) - keyNo += 1 - except winreg.error: - break - except EnvironmentError: - pass - if not installedVersions: - print("Can't find a windows 10 sdk") - return None - - # We don't want to automatically used the latest as that's going to always - # be a moving target. Github's automation has "10.0.16299.0", so we target - # that if it exists, otherwise we use the earliest installed version. - ver = "10.0.16299.0" - if ver not in installedVersions: - print("Windows 10 SDK version", ver, "is preferred, but that's not installed") - print("Installed versions are", installedVersions) - ver = installedVersions[0] - print("Using", ver) - # no idea what these 'um' and 'winv6.3' paths actually mean and whether - # hard-coding them is appropriate, but here we are... - include = [os.path.join(installRoot, "include", ver, "um")] - if not os.path.exists(os.path.join(include[0], "windows.h")): - print( - "Found Windows sdk in", include, "but it doesn't appear to have windows.h" - ) - return None - include.append(os.path.join(installRoot, "include", ver, "shared")) - lib = [os.path.join(installRoot, "lib", ver, "um")] - return {"include": include, "lib": lib} - - -sdk_info = find_platform_sdk_dir() -if not sdk_info: - print() - print("It looks like you are trying to build pywin32 in an environment without") - print("the necessary tools installed. It's much easier to grab binaries!") - print() - print("Please read the docstring at the top of this file, or read README.md") - print("for more information.") - print() - raise RuntimeError("Can't find the Windows SDK") - def find_visual_studio_file(pattern): try: @@ -491,23 +424,6 @@ def finalize_options(self): self.excluded_extensions = [] # list of (ext, why) self.swig_cpp = True # hrm - deprecated - should use swig_opts=-c++?? - def _fixup_sdk_dirs(self): - assert self.compiler.initialized # if not, our env changes will be lost! - - for extra in sdk_info["include"]: - if extra not in self.compiler.include_dirs: - log.warn("distutils should meanwhile provide SDK include dir %s", extra) - assert os.path.isdir(extra), "%s doesn't exist!" % (extra,) - self.compiler.add_include_dir(extra) - for extra in sdk_info["lib"]: - extra = os.path.join(extra, self.plat_dir) - if extra not in self.compiler.library_dirs: - assert os.path.isdir(extra), "%s doesn't exist!" % (extra,) - self.compiler.add_library_dir(extra) - - log.debug("After SDK processing, includes are %s", self.compiler.include_dirs) - log.debug("After SDK processing, libs are %s", self.compiler.library_dirs) - def _why_cant_build_extension(self, ext): # Return None, or a reason it can't be built. # Exclude exchange 32-bit utility libraries from 64-bit @@ -663,8 +579,6 @@ def build_extensions(self): 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', # 'pythonwin' etc), as distutils doesn't seem to like the concept # of multiple top-level directories.