aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/msvc.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2017-04-07 21:52:18 -0400
committerJason R. Coombs <jaraco@jaraco.com>2017-04-07 21:52:30 -0400
commitac59ef12d16c13533ead6401bdb4727016be77e3 (patch)
tree6bd18acbc310c125b2f57e1fd3a8a9450d1b63a5 /setuptools/msvc.py
parent20b3b3eaa74935d4854b63f75d893def27a4248e (diff)
downloadexternal_python_setuptools-ac59ef12d16c13533ead6401bdb4727016be77e3.tar.gz
external_python_setuptools-ac59ef12d16c13533ead6401bdb4727016be77e3.tar.bz2
external_python_setuptools-ac59ef12d16c13533ead6401bdb4727016be77e3.zip
extract two functions for guessing the VC version; ref #995
Diffstat (limited to 'setuptools/msvc.py')
-rw-r--r--setuptools/msvc.py41
1 files changed, 25 insertions, 16 deletions
diff --git a/setuptools/msvc.py b/setuptools/msvc.py
index 71fe24cd..cf556ad3 100644
--- a/setuptools/msvc.py
+++ b/setuptools/msvc.py
@@ -530,22 +530,7 @@ class SystemInfo:
"""
self.VSInstallDir
- # Default path starting VS2017
- guess_vc = ''
- if self.vc_ver > 14.0:
- 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]
- guess_vc = os.path.join(guess_vc, vc_exact_ver)
- except (OSError, IOError, IndexError):
- guess_vc = ''
-
- # Legacy default path
- if not guess_vc:
- 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
reg_path = os.path.join(self.ri.vc_for_python, '%0.1f' % self.vc_ver)
@@ -561,6 +546,30 @@ class SystemInfo:
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
def WindowsSdkVersion(self):
"""