Commit 9abc044e authored by J. Goutin's avatar J. Goutin Committed by GitHub

Some fixes

- Fix issue #593
- Fix some forgotten "vcver" => "vc_ver" renames in previous commit.
- Add comment on why I didn't followed PEP8 for some variables names.
parent f9b1e673
...@@ -202,7 +202,7 @@ def msvc14_get_vc_env(plat_spec): ...@@ -202,7 +202,7 @@ def msvc14_get_vc_env(plat_spec):
# If error, try to set environment directly # If error, try to set environment directly
try: try:
return EnvironmentInfo(plat_spec, vcvermin=14.0).return_env() return EnvironmentInfo(plat_spec, vc_ver_min=14.0).return_env()
except distutils.errors.DistutilsPlatformError as exc: except distutils.errors.DistutilsPlatformError as exc:
_augment_exception(exc, 14.0) _augment_exception(exc, 14.0)
raise raise
...@@ -237,7 +237,7 @@ def _augment_exception(exc, version, arch=''): ...@@ -237,7 +237,7 @@ def _augment_exception(exc, version, arch=''):
message += ' Get it with "Microsoft Windows SDK 7.1": ' message += ' Get it with "Microsoft Windows SDK 7.1": '
message += msdownload % 8279 message += msdownload % 8279
exc.args[0] = message exc.args = (message, )
class PlatformInfo: class PlatformInfo:
...@@ -460,6 +460,8 @@ class SystemInfo: ...@@ -460,6 +460,8 @@ class SystemInfo:
vc_ver: float vc_ver: float
Required Microsoft Visual C++ version. Required Microsoft Visual C++ version.
""" """
# Variables and properties in this class use originals CamelCase variables
# names from Microsoft source files for more easy comparaison.
WinDir = safe_env['WinDir'] WinDir = safe_env['WinDir']
ProgramFiles = safe_env['ProgramFiles'] ProgramFiles = safe_env['ProgramFiles']
ProgramFilesx86 = os.environ.get('ProgramFiles(x86)', ProgramFiles) ProgramFilesx86 = os.environ.get('ProgramFiles(x86)', ProgramFiles)
...@@ -481,7 +483,7 @@ class SystemInfo: ...@@ -481,7 +483,7 @@ 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) vckeys = (self.ri.vc, self.ri.vc_for_python)
vsvers = [] vc_vers = []
for hkey in self.ri.HKEYS: for hkey in self.ri.HKEYS:
for key in vckeys: for key in vckeys:
try: try:
...@@ -492,18 +494,18 @@ class SystemInfo: ...@@ -492,18 +494,18 @@ class SystemInfo:
for i in range(values): for i in range(values):
try: try:
ver = float(winreg.EnumValue(bkey, i)[0]) ver = float(winreg.EnumValue(bkey, i)[0])
if ver not in vsvers: if ver not in vc_vers:
vsvers.append(ver) vc_vers.append(ver)
except ValueError: except ValueError:
pass pass
for i in range(subkeys): for i in range(subkeys):
try: try:
ver = float(winreg.EnumKey(bkey, i)) ver = float(winreg.EnumKey(bkey, i))
if ver not in vsvers: if ver not in vc_vers:
vsvers.append(ver) vc_vers.append(ver)
except ValueError: except ValueError:
pass pass
return sorted(vsvers) return sorted(vc_vers)
@property @property
def VSInstallDir(self): def VSInstallDir(self):
...@@ -527,18 +529,18 @@ class SystemInfo: ...@@ -527,18 +529,18 @@ class SystemInfo:
guess_vc = os.path.join(self.ProgramFilesx86, default) guess_vc = os.path.join(self.ProgramFilesx86, default)
# Try to get "VC++ for Python" path from registry as default path # Try to get "VC++ for Python" path from registry as default path
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)
python_vc = self.ri.lookup(path, 'installdir') python_vc = self.ri.lookup(reg_path, 'installdir')
default_vc = os.path.join(python_vc, 'VC') if python_vc else guess_vc default_vc = os.path.join(python_vc, 'VC') if python_vc else guess_vc
# Try to get path from registry, if fail use default path # Try to get path from registry, if fail use default path
result = self.ri.lookup(self.ri.vc, '%0.1f' % self.vc_ver) or default_vc path = self.ri.lookup(self.ri.vc, '%0.1f' % self.vc_ver) or default_vc
if not os.path.isdir(result): if not os.path.isdir(path):
msg = 'Microsoft Visual C++ directory not found' msg = 'Microsoft Visual C++ directory not found'
raise distutils.errors.DistutilsPlatformError(msg) raise distutils.errors.DistutilsPlatformError(msg)
return result return path
@property @property
def WindowsSdkVersion(self): def WindowsSdkVersion(self):
...@@ -758,6 +760,8 @@ class EnvironmentInfo: ...@@ -758,6 +760,8 @@ class EnvironmentInfo:
vc_min_ver: float vc_min_ver: float
Minimum Microsoft Visual C++ version. Minimum Microsoft Visual C++ version.
""" """
# 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=None):
self.pi = PlatformInfo(arch) self.pi = PlatformInfo(arch)
self.ri = RegistryInfo(self.pi) self.ri = RegistryInfo(self.pi)
...@@ -773,7 +777,7 @@ class EnvironmentInfo: ...@@ -773,7 +777,7 @@ class EnvironmentInfo:
""" """
Microsoft Visual C++ version. Microsoft Visual C++ version.
""" """
return self.si.vcver return self.si.vc_ver
@property @property
def VSTools(self): def VSTools(self):
...@@ -1101,7 +1105,7 @@ class EnvironmentInfo: ...@@ -1101,7 +1105,7 @@ class EnvironmentInfo:
self.FSharp], self.FSharp],
exists), exists),
) )
if self.vcver >= 14 and os.path.isfile(self.VCRuntimeRedist): if self.vc_ver >= 14 and os.path.isfile(self.VCRuntimeRedist):
env['py_vcruntime_redist'] = self.VCRuntimeRedist env['py_vcruntime_redist'] = self.VCRuntimeRedist
return env return env
......
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