Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
cosmetic changes to make more PEP8 compliant
  • Loading branch information
tonyroberts committed Mar 19, 2014
commit 71c0f1e3d06ccf8e9c576d0efdedd22813abd775
45 changes: 26 additions & 19 deletions pythonnet/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,47 @@
CONFIG = "Release" # Release or Debug
DEVTOOLS = "MsDev" if sys.platform == "win32" else "Mono"
VERBOSITY = "minimal" # quiet, minimal, normal, detailed, diagnostic
PLATFORM = "x64" if architecture()[0] == "64bit" else "x86"

def FindMsBuildPath():

def _find_msbuild_path():
"""Return full path to msbuild.exe"""
import _winreg

aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
hreg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
try:
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"]
aKey = None
for key in keysToCheck:
keys_to_check = [
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"
]
hkey = None
for key in keys_to_check:
try:
aKey = _winreg.OpenKey(aReg, key)
hkey = _winreg.OpenKey(hreg, key)
break
except WindowsError:
pass

if aKey==None:
raise RuntimeError("MSBUILD.exe could not be found")
if hkey is None:
raise RuntimeError("msbuild.exe could not be found")

try:
val, type = _winreg.QueryValueEx(aKey, "MSBuildToolsPath")

if type!=_winreg.REG_SZ:
raise RuntimeError("MSBUILD.exe could not be found")
val, type_ = _winreg.QueryValueEx(hkey, "MSBuildToolsPath")
if type_ != _winreg.REG_SZ:
raise RuntimeError("msbuild.exe could not be found")
finally:
aKey.Close()
hkey.Close()
finally:
aReg.Close()
hreg.Close()

msbuildpath = os.path.join(val, "msbuild.exe")
return msbuildpath


if DEVTOOLS == "MsDev":
_xbuild = "\"%s\"" % FindMsBuildPath()
_xbuild = "\"%s\"" % _find_msbuild_path()
_defines_sep = ";"
_config = "%sWin" % CONFIG
_npython_exe = "nPython.exe"
Expand All @@ -64,7 +71,6 @@ def FindMsBuildPath():
else:
raise NotImplementedError("DevTools %s not supported (use MsDev or Mono)" % DEVTOOLS)

_platform = "x64" if architecture()[0] == "64bit" else "x86"

class PythonNET_BuildExt(build_ext):

Expand Down Expand Up @@ -92,15 +98,16 @@ def build_extension(self, ext):
_xbuild,
"pythonnet.sln",
"/p:Configuration=%s" % _config,
"/p:Platform=%s" % _platform,
"/p:Platform=%s" % PLATFORM,
"/p:DefineConstants=\"%s\"" % _defines_sep.join(defines),
"/p:PythonBuildDir=%s" % os.path.abspath(dest_dir),
"/verbosity:%s" % VERBOSITY,
]

self.announce("Building: %s" % " ".join(cmd))
check_call(" ".join(cmd + ["/t:Clean"]), shell=(True if DEVTOOLS=="Mono" else False))
check_call(" ".join(cmd + ["/t:Build"]), shell=(True if DEVTOOLS=="Mono" else False))
use_shell = True if DEVTOOLS == "Mono" else False
check_call(" ".join(cmd + ["/t:Clean"]), shell=use_shell)
check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell)

if DEVTOOLS == "Mono":
self._build_monoclr(ext)
Expand Down