17
17
CONFIG = "Release" # Release or Debug
18
18
DEVTOOLS = "MsDev" if sys .platform == "win32" else "Mono"
19
19
VERBOSITY = "minimal" # quiet, minimal, normal, detailed, diagnostic
20
+ PLATFORM = "x64" if architecture ()[0 ] == "64bit" else "x86"
20
21
21
- def FindMsBuildPath ():
22
+
23
+ def _find_msbuild_path ():
24
+ """Return full path to msbuild.exe"""
22
25
import _winreg
23
26
24
- aReg = _winreg .ConnectRegistry (None ,_winreg .HKEY_LOCAL_MACHINE )
27
+ hreg = _winreg .ConnectRegistry (None , _winreg .HKEY_LOCAL_MACHINE )
25
28
try :
26
- keysToCheck = [r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\12.0" , r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0" , r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\3.5" , r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\2.0" ]
27
- aKey = None
28
- for key in keysToCheck :
29
+ keys_to_check = [
30
+ r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\12.0" ,
31
+ r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0" ,
32
+ r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\3.5" ,
33
+ r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\2.0"
34
+ ]
35
+ hkey = None
36
+ for key in keys_to_check :
29
37
try :
30
- aKey = _winreg .OpenKey (aReg , key )
38
+ hkey = _winreg .OpenKey (hreg , key )
31
39
break
32
40
except WindowsError :
33
41
pass
34
42
35
- if aKey == None :
36
- raise RuntimeError ("MSBUILD .exe could not be found" )
43
+ if hkey is None :
44
+ raise RuntimeError ("msbuild .exe could not be found" )
37
45
38
46
try :
39
- val , type = _winreg .QueryValueEx (aKey , "MSBuildToolsPath" )
40
-
41
- if type != _winreg .REG_SZ :
42
- raise RuntimeError ("MSBUILD.exe could not be found" )
47
+ val , type_ = _winreg .QueryValueEx (hkey , "MSBuildToolsPath" )
48
+ if type_ != _winreg .REG_SZ :
49
+ raise RuntimeError ("msbuild.exe could not be found" )
43
50
finally :
44
- aKey .Close ()
51
+ hkey .Close ()
45
52
finally :
46
- aReg .Close ()
53
+ hreg .Close ()
47
54
48
55
msbuildpath = os .path .join (val , "msbuild.exe" )
49
56
return msbuildpath
50
57
51
58
52
59
if DEVTOOLS == "MsDev" :
53
- _xbuild = "\" %s\" " % FindMsBuildPath ()
60
+ _xbuild = "\" %s\" " % _find_msbuild_path ()
54
61
_defines_sep = ";"
55
62
_config = "%sWin" % CONFIG
56
63
_npython_exe = "nPython.exe"
@@ -64,7 +71,6 @@ def FindMsBuildPath():
64
71
else :
65
72
raise NotImplementedError ("DevTools %s not supported (use MsDev or Mono)" % DEVTOOLS )
66
73
67
- _platform = "x64" if architecture ()[0 ] == "64bit" else "x86"
68
74
69
75
class PythonNET_BuildExt (build_ext ):
70
76
@@ -92,15 +98,16 @@ def build_extension(self, ext):
92
98
_xbuild ,
93
99
"pythonnet.sln" ,
94
100
"/p:Configuration=%s" % _config ,
95
- "/p:Platform=%s" % _platform ,
101
+ "/p:Platform=%s" % PLATFORM ,
96
102
"/p:DefineConstants=\" %s\" " % _defines_sep .join (defines ),
97
103
"/p:PythonBuildDir=%s" % os .path .abspath (dest_dir ),
98
104
"/verbosity:%s" % VERBOSITY ,
99
105
]
100
106
101
107
self .announce ("Building: %s" % " " .join (cmd ))
102
- check_call (" " .join (cmd + ["/t:Clean" ]), shell = (True if DEVTOOLS == "Mono" else False ))
103
- check_call (" " .join (cmd + ["/t:Build" ]), shell = (True if DEVTOOLS == "Mono" else False ))
108
+ use_shell = True if DEVTOOLS == "Mono" else False
109
+ check_call (" " .join (cmd + ["/t:Clean" ]), shell = use_shell )
110
+ check_call (" " .join (cmd + ["/t:Build" ]), shell = use_shell )
104
111
105
112
if DEVTOOLS == "Mono" :
106
113
self ._build_monoclr (ext )
0 commit comments