Commit 2c6dc33a authored by Jason R. Coombs's avatar Jason R. Coombs

Merge pull request #995 from JGoutin.

parents 4b664a67 76ac9dcb
v34.4.0 v34.4.0
------- -------
* #995: In MSVC support, add support for Microsoft
Build Tools 2017.
* #999 via #1007: Extend support for declarative package * #999 via #1007: Extend support for declarative package
config in a setup.cfg file to include the options config in a setup.cfg file to include the options
``python_requires`` and ``py_modules``. ``python_requires`` and ``py_modules``.
......
...@@ -13,6 +13,7 @@ Microsoft Visual C++ 10.0: ...@@ -13,6 +13,7 @@ Microsoft Visual C++ 10.0:
Microsoft Visual C++ 14.0: Microsoft Visual C++ 14.0:
Microsoft Visual C++ Build Tools 2015 (x86, x64, arm) Microsoft Visual C++ Build Tools 2015 (x86, x64, arm)
Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64)
""" """
import os import os
...@@ -150,6 +151,7 @@ def msvc14_get_vc_env(plat_spec): ...@@ -150,6 +151,7 @@ def msvc14_get_vc_env(plat_spec):
------------------------- -------------------------
Microsoft Visual C++ 14.0: Microsoft Visual C++ 14.0:
Microsoft Visual C++ Build Tools 2015 (x86, x64, arm) Microsoft Visual C++ Build Tools 2015 (x86, x64, arm)
Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64)
Parameters Parameters
---------- ----------
...@@ -411,7 +413,7 @@ class RegistryInfo: ...@@ -411,7 +413,7 @@ class RegistryInfo:
------ ------
str: value str: value
""" """
node64 = '' if self.pi.current_is_x86() or x86 else r'\Wow6432Node' node64 = '' if self.pi.current_is_x86() or x86 else 'Wow6432Node'
return os.path.join('Software', node64, 'Microsoft', key) return os.path.join('Software', node64, 'Microsoft', key)
def lookup(self, key, name): def lookup(self, key, name):
...@@ -483,12 +485,13 @@ class SystemInfo: ...@@ -483,12 +485,13 @@ class SystemInfo:
""" """
Find all available Microsoft Visual C++ versions. Find all available Microsoft Visual C++ versions.
""" """
vckeys = (self.ri.vc, self.ri.vc_for_python) ms = self.ri.microsoft
vckeys = (self.ri.vc, self.ri.vc_for_python, self.ri.vs)
vc_vers = [] vc_vers = []
for hkey in self.ri.HKEYS: for hkey in self.ri.HKEYS:
for key in vckeys: for key in vckeys:
try: try:
bkey = winreg.OpenKey(hkey, key, 0, winreg.KEY_READ) bkey = winreg.OpenKey(hkey, ms(key), 0, winreg.KEY_READ)
except (OSError, IOError): except (OSError, IOError):
continue continue
subkeys, values, _ = winreg.QueryInfoKey(bkey) subkeys, values, _ = winreg.QueryInfoKey(bkey)
...@@ -525,9 +528,9 @@ class SystemInfo: ...@@ -525,9 +528,9 @@ class SystemInfo:
""" """
Microsoft Visual C++ directory. Microsoft Visual C++ directory.
""" """
# Default path self.VSInstallDir
default = r'Microsoft Visual Studio %0.1f\VC' % self.vc_ver
guess_vc = os.path.join(self.ProgramFilesx86, default) guess_vc = self._guess_vc() or self._guess_vc_legacy()
# Try to get "VC++ for Python" path from registry as default path # Try to get "VC++ for Python" path from registry as default path
reg_path = os.path.join(self.ri.vc_for_python, '%0.1f' % self.vc_ver) reg_path = os.path.join(self.ri.vc_for_python, '%0.1f' % self.vc_ver)
...@@ -543,6 +546,30 @@ class SystemInfo: ...@@ -543,6 +546,30 @@ class SystemInfo:
return path return path
def _guess_vc(self):
"""
Locate Visual C for 2017
"""
if self.vc_ver <= 14.0:
return
default = r'VC\Tools\MSVC'
guess_vc = os.path.join(self.VSInstallDir, default)
# Subdir with VC exact version as name
try:
vc_exact_ver = os.listdir(guess_vc)[-1]
return os.path.join(guess_vc, vc_exact_ver)
except (OSError, IOError, IndexError):
pass
def _guess_vc_legacy(self):
"""
Locate Visual C for versions prior to 2017
"""
default = r'Microsoft Visual Studio %0.1f\VC' % self.vc_ver
return os.path.join(self.ProgramFilesx86, default)
@property @property
def WindowsSdkVersion(self): def WindowsSdkVersion(self):
""" """
...@@ -725,8 +752,10 @@ class SystemInfo: ...@@ -725,8 +752,10 @@ class SystemInfo:
bits: int bits: int
Platform number of bits: 32 or 64. Platform number of bits: 32 or 64.
""" """
# Find actual .NET version # Find actual .NET version in registry
ver = self.ri.lookup(self.ri.vc, 'frameworkver%d' % bits) or '' 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 ''
# Set .NET versions for specified MSVC++ version # Set .NET versions for specified MSVC++ version
if self.vc_ver >= 12.0: if self.vc_ver >= 12.0:
...@@ -740,6 +769,18 @@ class SystemInfo: ...@@ -740,6 +769,18 @@ class SystemInfo:
frameworkver = ('v3.0', 'v2.0.50727') frameworkver = ('v3.0', 'v2.0.50727')
return frameworkver return frameworkver
def _find_dot_net_in(self, dot_net_dir):
"""
Find .Net in the Framework folder
"""
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')
)
return next(matching_dirs, None)
class EnvironmentInfo: class EnvironmentInfo:
""" """
...@@ -810,6 +851,9 @@ class EnvironmentInfo: ...@@ -810,6 +851,9 @@ class EnvironmentInfo:
""" """
Microsoft Visual C++ & Microsoft Foundation Class Libraries Microsoft Visual C++ & Microsoft Foundation Class Libraries
""" """
if self.vc_ver >= 15.0:
arch_subdir = self.pi.target_dir(x64=True)
else:
arch_subdir = self.pi.target_dir(hidex86=True) arch_subdir = self.pi.target_dir(hidex86=True)
paths = ['Lib%s' % arch_subdir, r'ATLMFC\Lib%s' % arch_subdir] paths = ['Lib%s' % arch_subdir, r'ATLMFC\Lib%s' % arch_subdir]
...@@ -840,10 +884,20 @@ class EnvironmentInfo: ...@@ -840,10 +884,20 @@ class EnvironmentInfo:
if arch_subdir: if arch_subdir:
tools += [os.path.join(si.VCInstallDir, 'Bin%s' % arch_subdir)] tools += [os.path.join(si.VCInstallDir, 'Bin%s' % arch_subdir)]
if self.vc_ver >= 14.0: if self.vc_ver == 14.0:
path = 'Bin%s' % self.pi.current_dir(hidex86=True) path = 'Bin%s' % self.pi.current_dir(hidex86=True)
tools += [os.path.join(si.VCInstallDir, path)] tools += [os.path.join(si.VCInstallDir, path)]
elif self.vc_ver >= 15.0:
host_dir = (r'bin\HostX86%s' if self.pi.current_is_x86() else
r'bin\HostX64%s')
tools += [os.path.join(
si.VCInstallDir, host_dir % self.pi.target_dir(x64=True))]
if self.pi.current_cpu != self.pi.target_cpu:
tools += [os.path.join(
si.VCInstallDir, host_dir % self.pi.current_dir(x64=True))]
else: else:
tools += [os.path.join(si.VCInstallDir, 'Bin')] tools += [os.path.join(si.VCInstallDir, 'Bin')]
...@@ -933,13 +987,17 @@ class EnvironmentInfo: ...@@ -933,13 +987,17 @@ class EnvironmentInfo:
""" """
Microsoft Windows SDK Tools Microsoft Windows SDK Tools
""" """
return list(self._sdk_tools())
def _sdk_tools(self):
if self.vc_ver < 15.0:
bin_dir = 'Bin' if self.vc_ver <= 11.0 else r'Bin\x86' bin_dir = 'Bin' if self.vc_ver <= 11.0 else r'Bin\x86'
tools = [os.path.join(self.si.WindowsSdkDir, bin_dir)] yield os.path.join(self.si.WindowsSdkDir, bin_dir)
if not self.pi.current_is_x86(): if not self.pi.current_is_x86():
arch_subdir = self.pi.current_dir(x64=True) arch_subdir = self.pi.current_dir(x64=True)
path = 'Bin%s' % arch_subdir path = 'Bin%s' % arch_subdir
tools += [os.path.join(self.si.WindowsSdkDir, path)] yield os.path.join(self.si.WindowsSdkDir, path)
if self.vc_ver == 10.0 or self.vc_ver == 11.0: if self.vc_ver == 10.0 or self.vc_ver == 11.0:
if self.pi.target_is_x86(): if self.pi.target_is_x86():
...@@ -947,12 +1005,16 @@ class EnvironmentInfo: ...@@ -947,12 +1005,16 @@ class EnvironmentInfo:
else: else:
arch_subdir = self.pi.current_dir(hidex86=True, x64=True) arch_subdir = self.pi.current_dir(hidex86=True, x64=True)
path = r'Bin\NETFX 4.0 Tools%s' % arch_subdir path = r'Bin\NETFX 4.0 Tools%s' % arch_subdir
tools += [os.path.join(self.si.WindowsSdkDir, path)] yield os.path.join(self.si.WindowsSdkDir, path)
if self.si.WindowsSDKExecutablePath: elif self.vc_ver >= 15.0:
tools += [self.si.WindowsSDKExecutablePath] path = os.path.join(self.si.WindowsSdkDir, 'Bin')
arch_subdir = self.pi.current_dir(x64=True)
sdkver = self._get_content_dirname(path).rstrip('\\')
yield os.path.join(path, '%s%s' % (sdkver, arch_subdir))
return tools if self.si.WindowsSDKExecutablePath:
yield self.si.WindowsSDKExecutablePath
@property @property
def SdkSetup(self): def SdkSetup(self):
...@@ -1023,10 +1085,21 @@ class EnvironmentInfo: ...@@ -1023,10 +1085,21 @@ class EnvironmentInfo:
""" """
if self.vc_ver < 12.0: if self.vc_ver < 12.0:
return [] return []
elif self.vc_ver < 15.0:
base_path = self.si.ProgramFilesx86
arch_subdir = self.pi.current_dir(hidex86=True) arch_subdir = self.pi.current_dir(hidex86=True)
else:
base_path = self.si.VSInstallDir
arch_subdir = ''
path = r'MSBuild\%0.1f\bin%s' % (self.vc_ver, arch_subdir) path = r'MSBuild\%0.1f\bin%s' % (self.vc_ver, arch_subdir)
return [os.path.join(self.si.ProgramFilesx86, path)] build = [os.path.join(base_path, path)]
if self.vc_ver >= 15.0:
# Add Roslyn C# & Visual Basic Compiler
build += [os.path.join(base_path, path, 'Roslyn')]
return build
@property @property
def HTMLHelpWorkshop(self): def HTMLHelpWorkshop(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment