Commit dd70b3b6 authored by Jason R. Coombs's avatar Jason R. Coombs

Extract function for _augment_exception.

parent b85f1ed5
...@@ -54,8 +54,6 @@ def find_vcvarsall(version): ...@@ -54,8 +54,6 @@ def find_vcvarsall(version):
return unpatched['find_vcvarsall'](version) return unpatched['find_vcvarsall'](version)
def query_vcvarsall(version, arch='x86', *args, **kwargs): def query_vcvarsall(version, arch='x86', *args, **kwargs):
message = ''
# Try to get environement from vcvarsall.bat (Classical way) # Try to get environement from vcvarsall.bat (Classical way)
try: try:
return unpatched['query_vcvarsall'](version, arch, *args, **kwargs) return unpatched['query_vcvarsall'](version, arch, *args, **kwargs)
...@@ -70,10 +68,18 @@ def query_vcvarsall(version, arch='x86', *args, **kwargs): ...@@ -70,10 +68,18 @@ def query_vcvarsall(version, arch='x86', *args, **kwargs):
try: try:
return _compute_env(version, arch) return _compute_env(version, arch)
except distutils.errors.DistutilsPlatformError as exc: except distutils.errors.DistutilsPlatformError as exc:
_augment_exception(exc, version)
raise
def _augment_exception(exc, version):
"""
Add details to the exception message to help guide the user
as to what action will resolve it.
"""
# Error if MSVC++ directory not found or environment not set # Error if MSVC++ directory not found or environment not set
message = exc.args[0] message = exc.args[0]
# Raise error
if message and "vcvarsall.bat" in message: if message and "vcvarsall.bat" in message:
# Special error message if MSVC++ not installed # Special error message if MSVC++ not installed
message = 'Microsoft Visual C++ %0.1f is required (%s).' %\ message = 'Microsoft Visual C++ %0.1f is required (%s).' %\
...@@ -88,7 +94,7 @@ def query_vcvarsall(version, arch='x86', *args, **kwargs): ...@@ -88,7 +94,7 @@ def query_vcvarsall(version, arch='x86', *args, **kwargs):
message += ' Get it with "Microsoft Windows SDK for Windows 7": ' message += ' Get it with "Microsoft Windows SDK for Windows 7": '
message += r'www.microsoft.com/download/details.aspx?id=8279' message += r'www.microsoft.com/download/details.aspx?id=8279'
raise distutils.errors.DistutilsPlatformError(message) exc.args[0] = message
class PlatformInfo: class PlatformInfo:
......
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