diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000000000..a9d5ace13
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,14 @@
+language: python
+python:
+ - 2.7
+before_install:
+ - sudo apt-get install software-properties-common
+ - 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
+install:
+ - cd pythonnet
+ - python setupmono.py build_ext --inplace
+script:
+ - export PYTHONPATH=`pwd`
+ - ./npython src/tests/runtests.py
diff --git a/pythonnet/pythonnet.sln b/pythonnet/pythonnet.sln
index a1613ef10..14c73d359 100644
--- a/pythonnet/pythonnet.sln
+++ b/pythonnet/pythonnet.sln
@@ -89,18 +89,10 @@ Global
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x64.Build.0 = Release|x64
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.ActiveCfg = Release|x86
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.Build.0 = Release|x86
- {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x64.ActiveCfg = DebugMono|x64
- {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x64.Build.0 = DebugMono|x64
- {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x86.ActiveCfg = DebugMono|x86
- {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x86.Build.0 = DebugMono|x86
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.ActiveCfg = DebugWin|x64
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.Build.0 = DebugWin|x64
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.ActiveCfg = DebugWin|x86
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.Build.0 = DebugWin|x86
- {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64
- {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x64.Build.0 = ReleaseMono|x64
- {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86
- {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x86.Build.0 = ReleaseMono|x86
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.Build.0 = ReleaseWin|x64
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86
diff --git a/pythonnet/setupmono.py b/pythonnet/setupmono.py
new file mode 100644
index 000000000..bf13fb5a9
--- /dev/null
+++ b/pythonnet/setupmono.py
@@ -0,0 +1,141 @@
+"""
+Setup script for building clr.pyd and dependencies using mono and into
+an egg or wheel.
+"""
+from setuptools import setup, Extension
+from distutils.command.build_ext import build_ext
+from distutils.sysconfig import get_config_vars
+from platform import architecture
+from subprocess import check_output, check_call
+import shutil
+import sys
+import os
+
+CONFIG = "Release" # Release or Debug
+DEVTOOLS = "Mono" # Mono or MsDev
+VERBOSITY = "minimal" # quiet, minimal, normal, detailed, diagnostic
+
+if DEVTOOLS == "MsDev":
+ from distutils import msvc9compiler
+ msvc9compiler.VERSION = 11
+
+ cc = msvc9compiler.MSVCCompiler()
+ cc.initialize()
+ _xbuild = cc.find_exe("msbuild.exe")
+ _defines_sep = ";"
+ _config = "%sWin" % CONFIG
+
+elif DEVTOOLS == "Mono":
+ _xbuild = "xbuild"
+ _defines_sep = ","
+ _config = "%sMono" % CONFIG
+
+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):
+
+ def build_extension(self, ext):
+ """
+ Builds the .pyd file using msbuild or xbuild.
+ """
+ if ext.name != "clr":
+ return super(PythonNET_BuildExt, self).build_extension(ext)
+
+ dest_file = self.get_ext_fullpath(ext.name)
+ dest_dir = os.path.dirname(dest_file)
+ if not os.path.exists(dest_dir):
+ os.makedirs(dest_dir)
+
+ defines = [
+ "PYTHON%d%s" % (sys.version_info[:2]),
+ "UCS2" if sys.maxunicode < 0x10FFFF else "UCS4",
+ ]
+
+ if CONFIG == "Debug":
+ defines.extend(["DEBUG", "TRACE"])
+
+ cmd = [
+ _xbuild,
+ "pythonnet.sln",
+ "/p:Configuration=%s" % _config,
+ "/p:Platform=%s" % _platform,
+ "/p:DefineConstants=\"%s\"" % _defines_sep.join(defines),
+ "/p:PythonBuildDir=%s" % os.path.abspath(dest_dir),
+ "/p:NoNuGet=true",
+ "/verbosity:%s" % VERBOSITY,
+ ]
+
+ self.announce("Building: %s" % " ".join(cmd))
+ check_call(" ".join(cmd) + " /t:Clean", shell=True)
+ check_call(" ".join(cmd) + " /t:Build", shell=True)
+
+ if DEVTOOLS == "Mono":
+ self._build_monoclr(ext)
+
+
+ def _build_monoclr(self, ext):
+ mono_libs = check_output("pkg-config --libs mono-2", shell=True)
+ mono_cflags = check_output("pkg-config --cflags mono-2", shell=True)
+ glib_libs = check_output("pkg-config --libs glib-2.0", shell=True)
+ glib_cflags = check_output("pkg-config --cflags glib-2.0", shell=True)
+ cflags = mono_cflags.strip() + " " + glib_cflags.strip()
+ libs = mono_libs.strip() + " " + glib_libs.strip()
+
+ # build the clr python module
+ setup(name="monoclr",
+ ext_modules=[
+ Extension("clr",
+ sources=[
+ "src/monoclr/pynetinit.c",
+ "src/monoclr/clrmod.c"
+ ],
+ extra_compile_args=cflags.split(" "),
+ extra_link_args=libs.split(" "),
+ )]
+ )
+
+ # build the clr python executable
+ sources = [
+ "src/monoclr/pynetinit.c",
+ "src/monoclr/python.c",
+ ]
+
+ macros = ext.define_macros[:]
+ for undef in ext.undef_macros:
+ macros.append((undef,))
+
+ objects = self.compiler.compile(sources,
+ output_dir=self.build_temp,
+ macros=macros,
+ include_dirs=ext.include_dirs,
+ debug=self.debug,
+ extra_postargs=cflags.split(" "),
+ depends=ext.depends)
+
+ output_dir = os.path.dirname(self.get_ext_fullpath(ext.name))
+ py_libs = get_config_vars("BLDLIBRARY")[0]
+ libs += " " + py_libs
+
+ self.compiler.link_executable(objects,
+ "npython",
+ output_dir=output_dir,
+ libraries=self.get_libraries(ext),
+ library_dirs=ext.library_dirs,
+ runtime_library_dirs=ext.runtime_library_dirs,
+ extra_postargs=libs.split(" "),
+ debug=self.debug)
+
+
+if __name__ == "__main__":
+ setup(name="pythonnet",
+ ext_modules=[
+ Extension("clr", sources=[])
+ ],
+ cmdclass = {
+ "build_ext" : PythonNET_BuildExt
+ }
+ )
+
diff --git a/pythonnet/src/clrmodule/clrmodule.csproj b/pythonnet/src/clrmodule/clrmodule.csproj
index 8d5a35b7b..3254edd52 100644
--- a/pythonnet/src/clrmodule/clrmodule.csproj
+++ b/pythonnet/src/clrmodule/clrmodule.csproj
@@ -13,12 +13,13 @@
v4.0
512
..\..\
+ $(SolutionDir)
true
true
bin\x86\DebugMono\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x86
prompt
@@ -29,7 +30,7 @@
true
bin\x64\DebugMono\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x64
prompt
@@ -39,8 +40,7 @@
bin\x86\ReleaseMono\
-
-
+
true
pdbonly
x86
@@ -51,8 +51,7 @@
bin\x64\ReleaseMono\
-
-
+
true
pdbonly
x64
@@ -64,7 +63,7 @@
true
bin\x86\DebugWin\
- TRACE;DEBUG;DEBUG_PRINT
+ TRACE;DEBUG;DEBUG_PRINT
full
x86
prompt
@@ -75,7 +74,7 @@
true
bin\x64\DebugWin\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x64
prompt
@@ -85,8 +84,7 @@
bin\x86\ReleaseWin\
-
-
+
true
pdbonly
x86
@@ -97,8 +95,7 @@
bin\x64\ReleaseWin\
-
-
+
true
pdbonly
x64
@@ -122,20 +119,9 @@
-
- del "$(SolutionDir)clr.pyd"
-
-
- move "$(TargetPath)" "$(TargetDir)clr.pyd"
-copy "$(TargetDir)clr.pyd" "$(SolutionDir)"
-
-
-
-
\ No newline at end of file
diff --git a/pythonnet/src/console/Console.csproj b/pythonnet/src/console/Console.csproj
index 7d9c30110..ddf4cbe4e 100644
--- a/pythonnet/src/console/Console.csproj
+++ b/pythonnet/src/console/Console.csproj
@@ -17,20 +17,22 @@
python-clear.ico
10.0.0
2.0
+ ..\..\
+ $(SolutionDir)
True
full
False
bin\Debug\
- DEBUG;TRACE
+ DEBUG;TRACE
4
pdbonly
True
bin\Release\
- TRACE
+ TRACE
True
false
4
@@ -38,7 +40,7 @@
True
bin\EmbeddingTest\
- DEBUG;TRACE
+ DEBUG;TRACE
full
AnyCPU
4
@@ -47,7 +49,7 @@
True
bin\UnitTests\
- DEBUG;TRACE
+ DEBUG;TRACE
full
AnyCPU
4
@@ -56,7 +58,7 @@
True
bin\x86\Debug\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x86
true
@@ -69,7 +71,7 @@
True
bin\x86\Release\
- TRACE
+ TRACE
True
pdbonly
x86
@@ -81,7 +83,7 @@
True
bin\x86\EmbeddingTest\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x86
4
@@ -90,7 +92,7 @@
True
bin\x86\UnitTests\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x86
false
@@ -101,7 +103,7 @@
True
bin\DebugMono_x86\
- DEBUG;TRACE
+ DEBUG;TRACE
full
AnyCPU
4
@@ -110,7 +112,7 @@
True
bin\x86\DebugMono_x86\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x86
true
@@ -121,7 +123,7 @@
True
bin\x64\Debug\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x64
true
@@ -133,7 +135,7 @@
True
bin\x64\Release\
- TRACE
+ TRACE
True
pdbonly
x64
@@ -146,7 +148,7 @@
True
bin\x64\EmbeddingTest\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x64
false
@@ -158,7 +160,7 @@
True
bin\x64\UnitTests\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x64
false
@@ -169,7 +171,7 @@
True
bin\x64\DebugMono_x86\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x64
true
@@ -204,8 +206,7 @@
-
- copy "$(TargetPath)" "$(SolutionDir)"
-copy "$(TargetDir)*.pdb" "$(SolutionDir)"
-
+
+
+
\ No newline at end of file
diff --git a/pythonnet/src/embed_tests/Python.EmbeddingTest.csproj b/pythonnet/src/embed_tests/Python.EmbeddingTest.csproj
index 005d3daf2..acd7e2591 100644
--- a/pythonnet/src/embed_tests/Python.EmbeddingTest.csproj
+++ b/pythonnet/src/embed_tests/Python.EmbeddingTest.csproj
@@ -32,12 +32,13 @@
10.0.0
2.0
..\..\
+ $(SolutionDir)
true
-
+
true
bin\x86\DebugMono\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x86
prompt
@@ -48,7 +49,7 @@
true
bin\x64\DebugMono\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x64
prompt
@@ -58,7 +59,7 @@
bin\x86\ReleaseMono\
-
+
true
pdbonly
x86
@@ -69,7 +70,7 @@
bin\x64\ReleaseMono\
-
+
true
pdbonly
x64
@@ -78,11 +79,10 @@
true
false
-
true
bin\x86\DebugWin\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x86
prompt
@@ -93,7 +93,7 @@
true
bin\x64\DebugWin\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x64
prompt
@@ -103,7 +103,7 @@
bin\x86\ReleaseWin\
-
+
true
pdbonly
x86
@@ -114,7 +114,7 @@
bin\x64\ReleaseWin\
-
+
true
pdbonly
x64
@@ -134,7 +134,7 @@
-
+
@@ -169,13 +169,11 @@
+
-
- copy "$(TargetPath)" "$(SolutionDir)"
-copy "$(TargetDir)*.pdb" "$(SolutionDir)"
-
-
-
-
\ No newline at end of file
+
+
+
+
diff --git a/pythonnet/src/monoclr/clrmod.c b/pythonnet/src/monoclr/clrmod.c
index 2d2db389c..8b809b28f 100644
--- a/pythonnet/src/monoclr/clrmod.c
+++ b/pythonnet/src/monoclr/clrmod.c
@@ -37,7 +37,7 @@ initclr(void)
PyModule_AddObject(m, "facade", Py_True);
Py_INCREF(Py_True);
- pn_args = PyNet_Init(0);
+ pn_args = PyNet_Init(1);
if (pn_args->error) {
return;
}
diff --git a/pythonnet/src/monoclr/pynetclr.h b/pythonnet/src/monoclr/pynetclr.h
index 64c179092..c97db10cb 100644
--- a/pythonnet/src/monoclr/pynetclr.h
+++ b/pythonnet/src/monoclr/pynetclr.h
@@ -20,7 +20,7 @@
#include
#include
-#define MONO_VERSION "v2.0.50727"
+#define MONO_VERSION "v4.0.30319.1"
#define MONO_DOMAIN "Python.Runtime"
#define PR_ASSEMBLY "Python.Runtime.dll"
diff --git a/pythonnet/src/monoclr/pynetinit.c b/pythonnet/src/monoclr/pynetinit.c
index 51e44dc52..70468d15f 100644
--- a/pythonnet/src/monoclr/pynetinit.c
+++ b/pythonnet/src/monoclr/pynetinit.c
@@ -37,7 +37,7 @@ PyNet_Args* PyNet_Init(int ext) {
* if you are planning on using the dllmaps defined on the
* system configuration
*/
- //mono_config_parse(NULL);
+ mono_config_parse(NULL);
/* I can't use this call to run the main_thread_handler. The function
* runs it in another thread but *this* thread holds the Python
diff --git a/pythonnet/src/runtime/Python.Runtime.csproj b/pythonnet/src/runtime/Python.Runtime.csproj
index ebc2472bd..d4132da2c 100644
--- a/pythonnet/src/runtime/Python.Runtime.csproj
+++ b/pythonnet/src/runtime/Python.Runtime.csproj
@@ -8,11 +8,12 @@
false
Python.Runtime
Python.Runtime
- OnBuildSuccess
+ ..\..\
+ $(SolutionDir)
bin\x86\ReleaseMono\
- PYTHON27, UCS4
+ PYTHON27, UCS4
true
true
pdbonly
@@ -20,9 +21,9 @@
false
true
-
+
bin\x64\ReleaseMono\
- PYTHON27, UCS4
+ PYTHON27, UCS4
true
true
pdbonly
@@ -32,7 +33,7 @@
bin\x86\ReleaseWin\
- PYTHON27, UCS2
+ PYTHON27, UCS2
true
true
pdbonly
@@ -42,7 +43,7 @@
bin\x64\ReleaseWin\
- PYTHON27, UCS2
+ PYTHON27, UCS2
true
true
pdbonly
@@ -53,7 +54,7 @@
true
bin\x86\DebugMono\
- TRACE;DEBUG;PYTHON27,UCS4
+ TRACE;DEBUG;PYTHON27,UCS4
true
false
full
@@ -65,7 +66,7 @@
true
bin\x64\DebugMono\
- TRACE;DEBUG;PYTHON27,UCS4
+ TRACE;DEBUG;PYTHON27,UCS4
true
false
full
@@ -74,7 +75,7 @@
true
bin\x86\DebugWin\
- TRACE;DEBUG;PYTHON27,UCS2
+ TRACE;DEBUG;PYTHON27,UCS2
true
false
full
@@ -86,7 +87,7 @@
true
bin\x64\DebugWin\
- TRACE;DEBUG;PYTHON27,UCS2
+ TRACE;DEBUG;PYTHON27,UCS2
true
false
full
@@ -183,12 +184,7 @@
-
- call "$(ProjectDir)buildclrmodule.bat" $(Platform) "$(ProjectDir)" "$(TargetDir)clr.pyd"
-copy "$(TargetPath)" "$(SolutionDir)"
-copy "$(TargetDir)*.pdb" "$(SolutionDir)"
-copy "$(TargetDir)clr.pyd" "$(SolutionDir)"
-
- del "$(TargetDir)clr.pyd"
-
-
\ No newline at end of file
+
+
+
+
diff --git a/pythonnet/src/runtime/runtime.cs b/pythonnet/src/runtime/runtime.cs
index 1218f2b7d..6c3bad528 100644
--- a/pythonnet/src/runtime/runtime.cs
+++ b/pythonnet/src/runtime/runtime.cs
@@ -75,8 +75,10 @@ internal static void Initialize() {
is32bit = IntPtr.Size == 4;
- Runtime.Py_Initialize();
- Runtime.PyEval_InitThreads();
+ if (0 == Runtime.Py_IsInitialized()) {
+ Runtime.Py_Initialize();
+ Runtime.PyEval_InitThreads();
+ }
IntPtr dict = Runtime.PyImport_GetModuleDict();
IntPtr op = Runtime.PyDict_GetItemString(dict, "__builtin__");
diff --git a/pythonnet/src/testing/Python.Test.csproj b/pythonnet/src/testing/Python.Test.csproj
index dc678095a..19846c26f 100644
--- a/pythonnet/src/testing/Python.Test.csproj
+++ b/pythonnet/src/testing/Python.Test.csproj
@@ -8,14 +8,16 @@
false
Python.Test
Python.Test
- OnBuildSuccess
+ OnBuildSuccess
v4.0
-
+ ..\..\
+ $(SolutionDir)
+
true
bin\x86\DebugMono\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x86
prompt
@@ -26,7 +28,7 @@
true
bin\x64\DebugMono\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x64
prompt
@@ -36,7 +38,7 @@
bin\x86\ReleaseMono\
-
+
true
pdbonly
x86
@@ -47,7 +49,7 @@
bin\x64\ReleaseMono\
-
+
true
pdbonly
x64
@@ -59,7 +61,7 @@
true
bin\x86\DebugWin\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x86
prompt
@@ -70,7 +72,7 @@
true
bin\x64\DebugWin\
- DEBUG;TRACE
+ DEBUG;TRACE
full
x64
prompt
@@ -80,7 +82,7 @@
bin\x86\ReleaseWin\
-
+
true
pdbonly
x86
@@ -91,7 +93,7 @@
bin\x64\ReleaseWin\
-
+
true
pdbonly
x64
@@ -136,8 +138,9 @@
- copy "$(TargetPath)" "$(SolutionDir)"
-copy "$(TargetDir)*.pdb" "$(SolutionDir)"
-
+ $(SolutionDir)
-
\ No newline at end of file
+
+
+
+