Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions 4 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ before_install:
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ trusty main universe"
- sudo apt-get -qq update
- sudo apt-get -qq install mono-devel mono-gmcs mono-xbuild nunit-console
- sudo mozroots --import --machine --sync
- yes | sudo certmgr -ssl -m https://go.microsoft.com
- yes | sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net
- yes | sudo certmgr -ssl -m https://nuget.org
install:
- cd pythonnet
- python setup.py build_ext --inplace
Expand Down
71 changes: 52 additions & 19 deletions 71 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 All @@ -75,6 +81,9 @@ def build_extension(self, ext):
if ext.name != "clr":
return build_ext.build_extension(self, ext)

# install packages using nuget
self._install_packages()

dest_file = self.get_ext_fullpath(ext.name)
dest_dir = os.path.dirname(dest_file)
if not os.path.exists(dest_dir):
Expand All @@ -92,15 +101,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 Expand Up @@ -157,6 +167,29 @@ def _build_monoclr(self, ext):
debug=self.debug)


def _install_packages(self):
"""install packages using nuget"""
nuget = os.path.join("tools", "nuget", "nuget.exe")
use_shell = False
if DEVTOOLS == "Mono":
nuget = "mono %s" % nuget
use_shell = True

for dir in os.listdir("src"):
if DEVTOOLS == "Mono" and dir == "clrmodule":
continue
if DEVTOOLS != "Mono" and dir == "monoclr":
continue

packages_cfg = os.path.join("src", dir, "packages.config")
if not os.path.exists(packages_cfg):
continue

cmd = "%s install %s -o packages" % (nuget, packages_cfg)
self.announce("Installng packages for %s: %s" % (dir, cmd))
check_call(cmd, shell=use_shell)


class PythonNET_InstallLib(install_lib):

def install(self):
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.