Imported Upstream version 34.4.1 upstream/34.4.1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 14 Jan 2019 01:31:47 +0000 (10:31 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 14 Jan 2019 01:31:47 +0000 (10:31 +0900)
CHANGES.rst
setup.cfg
setup.py
setuptools/command/easy_install.py
setuptools/msvc.py
setuptools/py27compat.py

index 081e2cfed09ff541ee4b2ca4d62a4a7561c13d13..18583f0b898a874218eb6595bd1013472b73cd41 100644 (file)
@@ -1,8 +1,18 @@
+v34.4.1
+-------
+
+* #1008: In MSVC support, use always the last version available for Windows SDK and UCRT SDK.
+
+* #1008: In MSVC support, fix "vcruntime140.dll" returned path with Visual Studio 2017.
+
+* #992: In msvc.msvc9_query_vcvarsall, ensure the
+  returned dicts have str values and not Unicode for
+  compatibilty with os.environ.
+
 v34.4.0
 -------
 
-* #995: In MSVC support, add support for Microsoft
-  Build Tools 2017.
+* #995: In MSVC support, add support for "Microsoft Visual Studio 2017" and "Microsoft Visual Studio Build Tools 2017".
 
 * #999 via #1007: Extend support for declarative package
   config in a setup.cfg file to include the options
index fcade157dc7bf0afdc692ab7efdaf06e1b215f44..686da2f63b36accc274a557b2b7ca78ae931ba1a 100755 (executable)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 34.4.0
+current_version = 34.4.1
 commit = True
 tag = True
 
index 0ccc6631178c463028c4620c47ce00c55e636891..798cf845f128d3e0956f1e4c00cd1a2481a74b02 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -89,7 +89,7 @@ def pypi_link(pkg_filename):
 
 setup_params = dict(
     name="setuptools",
-    version="34.4.0",
+    version="34.4.1",
     description="Easily download, build, install, upgrade, and uninstall "
         "Python packages",
     author="Python Packaging Authority",
index ef83f7aed295e320fcac225d39fa9e3e74f5b53e..e30ca3ac169a037357c47476062fc213985039ff 100755 (executable)
@@ -474,8 +474,7 @@ class easy_install(Command):
         else:
             self.pth_file = None
 
-        PYTHONPATH = os.environ.get('PYTHONPATH', '').split(os.pathsep)
-        if instdir not in map(normalize_path, filter(None, PYTHONPATH)):
+        if instdir not in map(normalize_path, _pythonpath()):
             # only PYTHONPATH dirs need a site.py, so pretend it's there
             self.sitepy_installed = True
         elif self.multi_version and not os.path.exists(pth_file):
@@ -1348,10 +1347,21 @@ class easy_install(Command):
                 setattr(self, attr, val)
 
 
+def _pythonpath():
+    items = os.environ.get('PYTHONPATH', '').split(os.pathsep)
+    return filter(None, items)
+
+
 def get_site_dirs():
-    # return a list of 'site' dirs
-    sitedirs = [_f for _f in os.environ.get('PYTHONPATH',
-                                            '').split(os.pathsep) if _f]
+    """
+    Return a list of 'site' dirs
+    """
+
+    sitedirs = []
+
+    # start with PYTHONPATH
+    sitedirs.extend(_pythonpath())
+
     prefixes = [sys.prefix]
     if sys.exec_prefix != sys.prefix:
         prefixes.append(sys.exec_prefix)
index 35c02129e68243f78834702fdf2e5369f2e6f488..3110eaffe3a9cbdc891bd75cccf49e8874f882b5 100644 (file)
@@ -4,15 +4,16 @@ Improved support for Microsoft Visual C++ compilers.
 Known supported compilers:
 --------------------------
 Microsoft Visual C++ 9.0:
-    Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64);
-    Microsoft Windows SDK 7.0 (x86, x64, ia64);
+    Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64)
     Microsoft Windows SDK 6.1 (x86, x64, ia64)
+    Microsoft Windows SDK 7.0 (x86, x64, ia64)
 
 Microsoft Visual C++ 10.0:
     Microsoft Windows SDK 7.1 (x86, x64, ia64)
 
 Microsoft Visual C++ 14.0:
     Microsoft Visual C++ Build Tools 2015 (x86, x64, arm)
+    Microsoft Visual Studio 2017 (x86, x64, arm, arm64)
     Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64)
 """
 
@@ -26,6 +27,7 @@ from packaging.version import LegacyVersion
 from six.moves import filterfalse
 
 from .monkey import get_unpatched
+from . import py27compat
 
 if platform.system() == 'Windows':
     from six.moves import winreg
@@ -95,7 +97,7 @@ def msvc9_find_vcvarsall(version):
 
 def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs):
     """
-    Patched "distutils.msvc9compiler.query_vcvarsall" for support standalones
+    Patched "distutils.msvc9compiler.query_vcvarsall" for support extra
     compilers.
 
     Set environment without use of "vcvarsall.bat".
@@ -103,9 +105,9 @@ def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs):
     Known supported compilers
     -------------------------
     Microsoft Visual C++ 9.0:
-        Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64);
-        Microsoft Windows SDK 7.0 (x86, x64, ia64);
+        Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64)
         Microsoft Windows SDK 6.1 (x86, x64, ia64)
+        Microsoft Windows SDK 7.0 (x86, x64, ia64)
 
     Microsoft Visual C++ 10.0:
         Microsoft Windows SDK 7.1 (x86, x64, ia64)
@@ -134,15 +136,17 @@ def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs):
 
     # If error, try to set environment directly
     try:
-        return EnvironmentInfo(arch, ver).return_env()
+        env = EnvironmentInfo(arch, ver).return_env()
     except distutils.errors.DistutilsPlatformError as exc:
         _augment_exception(exc, ver, arch)
         raise
 
+    return py27compat.dict_values_strings(env)
+
 
 def msvc14_get_vc_env(plat_spec):
     """
-    Patched "distutils._msvccompiler._get_vc_env" for support standalones
+    Patched "distutils._msvccompiler._get_vc_env" for support extra
     compilers.
 
     Set environment without use of "vcvarsall.bat".
@@ -151,6 +155,7 @@ def msvc14_get_vc_env(plat_spec):
     -------------------------
     Microsoft Visual C++ 14.0:
         Microsoft Visual C++ Build Tools 2015 (x86, x64, arm)
+        Microsoft Visual Studio 2017 (x86, x64, arm, arm64)
         Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64)
 
     Parameters
@@ -472,14 +477,14 @@ class SystemInfo:
     def __init__(self, registry_info, vc_ver=None):
         self.ri = registry_info
         self.pi = self.ri.pi
-        if vc_ver:
-            self.vc_ver = vc_ver
-        else:
-            try:
-                self.vc_ver = self.find_available_vc_vers()[-1]
-            except IndexError:
-                err = 'No Microsoft Visual C++ version found'
-                raise distutils.errors.DistutilsPlatformError(err)
+        self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
+
+    def _find_latest_available_vc_ver(self):
+        try:
+            return self.find_available_vc_vers()[-1]
+        except IndexError:
+            err = 'No Microsoft Visual C++ version found'
+            raise distutils.errors.DistutilsPlatformError(err)
 
     def find_available_vc_vers(self):
         """
@@ -550,7 +555,6 @@ class SystemInfo:
         """
         Locate Visual C for 2017
         """
-
         if self.vc_ver <= 14.0:
             return
 
@@ -573,9 +577,8 @@ class SystemInfo:
     @property
     def WindowsSdkVersion(self):
         """
-        Microsoft Windows SDK versions.
+        Microsoft Windows SDK versions for specified MSVC++ version.
         """
-        # Set Windows SDK versions for specified MSVC++ version
         if self.vc_ver <= 9.0:
             return ('7.0', '6.1', '6.0a')
         elif self.vc_ver == 10.0:
@@ -587,6 +590,14 @@ class SystemInfo:
         elif self.vc_ver >= 14.0:
             return ('10.0', '8.1')
 
+    @property
+    def WindowsSdkLastVersion(self):
+        """
+        Microsoft Windows SDK last version
+        """
+        return self._use_last_dir_name(os.path.join(
+            self.WindowsSdkDir, 'lib'))
+
     @property
     def WindowsSdkDir(self):
         """
@@ -684,6 +695,14 @@ class SystemInfo:
                 break
         return sdkdir or ''
 
+    @property
+    def UniversalCRTSdkLastVersion(self):
+        """
+        Microsoft Universal C Runtime SDK last version
+        """
+        return self._use_last_dir_name(os.path.join(
+            self.UniversalCRTSdkDir, 'lib'))
+
     @property
     def NetFxSdkVersion(self):
         """
@@ -743,7 +762,7 @@ class SystemInfo:
         """
         return self._find_dot_net_versions(64)
 
-    def _find_dot_net_versions(self, bits=32):
+    def _find_dot_net_versions(self, bits):
         """
         Find Microsoft .NET Framework versions.
 
@@ -755,7 +774,7 @@ class SystemInfo:
         # Find actual .NET version in registry
         reg_ver = self.ri.lookup(self.ri.vc, 'frameworkver%d' % bits)
         dot_net_dir = getattr(self, 'FrameworkDir%d' % bits)
-        ver = reg_ver or self._find_dot_net_in(dot_net_dir) or ''
+        ver = reg_ver or self._use_last_dir_name(dot_net_dir, 'v') or ''
 
         # Set .NET versions for specified MSVC++ version
         if self.vc_ver >= 12.0:
@@ -769,17 +788,24 @@ class SystemInfo:
             frameworkver = ('v3.0', 'v2.0.50727')
         return frameworkver
 
-    def _find_dot_net_in(self, dot_net_dir):
+    def _use_last_dir_name(self, path, prefix=''):
         """
-        Find .Net in the Framework folder
+        Return name of the last dir in path or '' if no dir found.
+
+        Parameters
+        ----------
+        path: str
+            Use dirs in this path
+        prefix: str
+            Use only dirs startings by this prefix
         """
         matching_dirs = (
             dir_name
-            for dir_name in reversed(os.listdir(dot_net_dir))
-            if os.path.isdir(os.path.join(dot_net_dir, dir_name))
-            and dir_name.startswith('v')
+            for dir_name in reversed(os.listdir(path))
+            if os.path.isdir(os.path.join(path, dir_name)) and
+            dir_name.startswith(prefix)
         )
-        return next(matching_dirs, None)
+        return next(matching_dirs, None) or ''
 
 
 class EnvironmentInfo:
@@ -806,15 +832,14 @@ class EnvironmentInfo:
     # Variables and properties in this class use originals CamelCase variables
     # names from Microsoft source files for more easy comparaison.
 
-    def __init__(self, arch, vc_ver=None, vc_min_ver=None):
+    def __init__(self, arch, vc_ver=None, vc_min_ver=0):
         self.pi = PlatformInfo(arch)
         self.ri = RegistryInfo(self.pi)
         self.si = SystemInfo(self.ri, vc_ver)
 
-        if vc_min_ver:
-            if self.vc_ver < vc_min_ver:
-                err = 'No suitable Microsoft Visual C++ version found'
-                raise distutils.errors.DistutilsPlatformError(err)
+        if self.vc_ver < vc_min_ver:
+            err = 'No suitable Microsoft Visual C++ version found'
+            raise distutils.errors.DistutilsPlatformError(err)
 
     @property
     def vc_ver(self):
@@ -915,8 +940,8 @@ class EnvironmentInfo:
         else:
             arch_subdir = self.pi.target_dir(x64=True)
             lib = os.path.join(self.si.WindowsSdkDir, 'lib')
-            libver = self._get_content_dirname(lib)
-            return [os.path.join(lib, '%sum%s' % (libver, arch_subdir))]
+            libver = self._sdk_subdir
+            return [os.path.join(lib, '%sum%s' % (libver , arch_subdir))]
 
     @property
     def OSIncludes(self):
@@ -930,7 +955,7 @@ class EnvironmentInfo:
 
         else:
             if self.vc_ver >= 14.0:
-                sdkver = self._get_content_dirname(include)
+                sdkver = self._sdk_subdir
             else:
                 sdkver = ''
             return [os.path.join(include, '%sshared' % sdkver),
@@ -990,6 +1015,9 @@ class EnvironmentInfo:
         return list(self._sdk_tools())
 
     def _sdk_tools(self):
+        """
+        Microsoft Windows SDK Tools paths generator
+        """
         if self.vc_ver < 15.0:
             bin_dir = 'Bin' if self.vc_ver <= 11.0 else r'Bin\x86'
             yield os.path.join(self.si.WindowsSdkDir, bin_dir)
@@ -1010,12 +1038,20 @@ class EnvironmentInfo:
         elif self.vc_ver >= 15.0:
             path = os.path.join(self.si.WindowsSdkDir, 'Bin')
             arch_subdir = self.pi.current_dir(x64=True)
-            sdkver = self._get_content_dirname(path).rstrip('\\')
+            sdkver = self.si.WindowsSdkLastVersion
             yield os.path.join(path, '%s%s' % (sdkver, arch_subdir))
 
         if self.si.WindowsSDKExecutablePath:
             yield self.si.WindowsSDKExecutablePath
 
+    @property
+    def _sdk_subdir(self):
+        """
+        Microsoft Windows SDK version subdir
+        """
+        ucrtver = self.si.WindowsSdkLastVersion
+        return ('%s\\' % ucrtver) if ucrtver else ''
+
     @property
     def SdkSetup(self):
         """
@@ -1114,27 +1150,34 @@ class EnvironmentInfo:
     @property
     def UCRTLibraries(self):
         """
-        Microsoft Universal CRT Libraries
+        Microsoft Universal C Runtime SDK Libraries
         """
         if self.vc_ver < 14.0:
             return []
 
         arch_subdir = self.pi.target_dir(x64=True)
         lib = os.path.join(self.si.UniversalCRTSdkDir, 'lib')
-        ucrtver = self._get_content_dirname(lib)
+        ucrtver = self._ucrt_subdir
         return [os.path.join(lib, '%sucrt%s' % (ucrtver, arch_subdir))]
 
     @property
     def UCRTIncludes(self):
         """
-        Microsoft Universal CRT Include
+        Microsoft Universal C Runtime SDK Include
         """
         if self.vc_ver < 14.0:
             return []
 
         include = os.path.join(self.si.UniversalCRTSdkDir, 'include')
-        ucrtver = self._get_content_dirname(include)
-        return [os.path.join(include, '%sucrt' % ucrtver)]
+        return [os.path.join(include, '%sucrt' % self._ucrt_subdir)]
+
+    @property
+    def _ucrt_subdir(self):
+        """
+        Microsoft Universal C Runtime SDK version subdir
+        """
+        ucrtver = self.si.UniversalCRTSdkLastVersion
+        return ('%s\\' % ucrtver) if ucrtver else ''
 
     @property
     def FSharp(self):
@@ -1152,9 +1195,18 @@ class EnvironmentInfo:
         Microsoft Visual C++ runtime redistribuable dll
         """
         arch_subdir = self.pi.target_dir(x64=True)
-        vcruntime = 'redist%s\\Microsoft.VC%d0.CRT\\vcruntime%d0.dll'
-        vcruntime = vcruntime % (arch_subdir, self.vc_ver, self.vc_ver)
-        return os.path.join(self.si.VCInstallDir, vcruntime)
+        if self.vc_ver < 15:
+            redist_path = self.si.VCInstallDir
+            vcruntime = 'redist%s\\Microsoft.VC%d0.CRT\\vcruntime%d0.dll'
+        else:
+            redist_path = self.si.VCInstallDir.replace('\\Tools', '\\Redist')
+            vcruntime = 'onecore%s\\Microsoft.VC%d0.CRT\\vcruntime%d0.dll'
+
+        # Visual Studio 2017  is still Visual C++ 14.0
+        dll_ver = 14.0 if self.vc_ver == 15 else self.vc_ver
+
+        vcruntime = vcruntime % (arch_subdir, self.vc_ver, dll_ver)
+        return os.path.join(redist_path, vcruntime)
 
     def return_env(self, exists=True):
         """
@@ -1242,25 +1294,3 @@ class EnvironmentInfo:
                 if k not in seen:
                     seen_add(k)
                     yield element
-
-    def _get_content_dirname(self, path):
-        """
-        Return name of the first dir in path or '' if no dir found.
-
-        Parameters
-        ----------
-        path: str
-            Path where search dir.
-
-        Return
-        ------
-        foldername: str
-            "name\" or ""
-        """
-        try:
-            name = os.listdir(path)
-            if name:
-                return '%s\\' % name[0]
-            return ''
-        except (OSError, IOError):
-            return ''
index f0a80a8edac5946c464dd2fe7f1d5ae3aed07447..0f92488945b865c9fba82264b23e14fd464ff11e 100644 (file)
@@ -2,9 +2,10 @@
 Compatibility Support for Python 2.7 and earlier
 """
 
-import sys
 import platform
 
+import six
+
 
 def get_all_headers(message, key):
     """
@@ -13,16 +14,29 @@ def get_all_headers(message, key):
     return message.get_all(key)
 
 
-if sys.version_info < (3,):
-
+if six.PY2:
     def get_all_headers(message, key):
         return message.getheaders(key)
 
 
 linux_py2_ascii = (
-       platform.system() == 'Linux' and
-       sys.version_info < (3,)
+    platform.system() == 'Linux' and
+    six.PY2
 )
 
 rmtree_safe = str if linux_py2_ascii else lambda x: x
 """Workaround for http://bugs.python.org/issue24672"""
+
+
+def dict_values_strings(dict_):
+    """
+    Given a dict, make sure the text values are str.
+    """
+    if six.PY3:
+        return dict_
+
+    # When dropping Python 2.6 support, use a dict constructor
+    return dict(
+        (key, str(value))
+        for key, value in dict_.iteritems()
+    )