Skip to content

Commit b738fe1

Browse files
committed
Merge pull request #8 from tonyroberts/travis-ci
Build with mono on linux and add travis-ci settings
2 parents 98264a3 + 5300343 commit b738fe1

File tree

12 files changed

+243
-110
lines changed

12 files changed

+243
-110
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: python
2+
python:
3+
- 2.7
4+
before_install:
5+
- sudo apt-get install software-properties-common
6+
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ trusty main universe"
7+
- sudo apt-get -qq update
8+
- sudo apt-get -qq install mono-devel mono-gmcs mono-xbuild nunit-console
9+
install:
10+
- cd pythonnet
11+
- python setupmono.py build_ext --inplace
12+
script:
13+
- export PYTHONPATH=`pwd`
14+
- ./npython src/tests/runtests.py

pythonnet/pythonnet.sln

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,10 @@ Global
8989
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x64.Build.0 = Release|x64
9090
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.ActiveCfg = Release|x86
9191
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.Build.0 = Release|x86
92-
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x64.ActiveCfg = DebugMono|x64
93-
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x64.Build.0 = DebugMono|x64
94-
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x86.ActiveCfg = DebugMono|x86
95-
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x86.Build.0 = DebugMono|x86
9692
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.ActiveCfg = DebugWin|x64
9793
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.Build.0 = DebugWin|x64
9894
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.ActiveCfg = DebugWin|x86
9995
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.Build.0 = DebugWin|x86
100-
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64
101-
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x64.Build.0 = ReleaseMono|x64
102-
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86
103-
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x86.Build.0 = ReleaseMono|x86
10496
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64
10597
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.Build.0 = ReleaseWin|x64
10698
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86

pythonnet/setupmono.py

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
"""
2+
Setup script for building clr.pyd and dependencies using mono and into
3+
an egg or wheel.
4+
"""
5+
from setuptools import setup, Extension
6+
from distutils.command.build_ext import build_ext
7+
from distutils.sysconfig import get_config_vars
8+
from platform import architecture
9+
from subprocess import check_output, check_call
10+
import shutil
11+
import sys
12+
import os
13+
14+
CONFIG = "Release" # Release or Debug
15+
DEVTOOLS = "Mono" # Mono or MsDev
16+
VERBOSITY = "minimal" # quiet, minimal, normal, detailed, diagnostic
17+
18+
if DEVTOOLS == "MsDev":
19+
from distutils import msvc9compiler
20+
msvc9compiler.VERSION = 11
21+
22+
cc = msvc9compiler.MSVCCompiler()
23+
cc.initialize()
24+
_xbuild = cc.find_exe("msbuild.exe")
25+
_defines_sep = ";"
26+
_config = "%sWin" % CONFIG
27+
28+
elif DEVTOOLS == "Mono":
29+
_xbuild = "xbuild"
30+
_defines_sep = ","
31+
_config = "%sMono" % CONFIG
32+
33+
else:
34+
raise NotImplementedError("DevTools %s not supported (use MsDev or Mono)" % DEVTOOLS)
35+
36+
_platform = "x64" if architecture()[0] == "64bit" else "x86"
37+
38+
class PythonNET_BuildExt(build_ext):
39+
40+
def build_extension(self, ext):
41+
"""
42+
Builds the .pyd file using msbuild or xbuild.
43+
"""
44+
if ext.name != "clr":
45+
return super(PythonNET_BuildExt, self).build_extension(ext)
46+
47+
dest_file = self.get_ext_fullpath(ext.name)
48+
dest_dir = os.path.dirname(dest_file)
49+
if not os.path.exists(dest_dir):
50+
os.makedirs(dest_dir)
51+
52+
defines = [
53+
"PYTHON%d%s" % (sys.version_info[:2]),
54+
"UCS2" if sys.maxunicode < 0x10FFFF else "UCS4",
55+
]
56+
57+
if CONFIG == "Debug":
58+
defines.extend(["DEBUG", "TRACE"])
59+
60+
cmd = [
61+
_xbuild,
62+
"pythonnet.sln",
63+
"/p:Configuration=%s" % _config,
64+
"/p:Platform=%s" % _platform,
65+
"/p:DefineConstants=\"%s\"" % _defines_sep.join(defines),
66+
"/p:PythonBuildDir=%s" % os.path.abspath(dest_dir),
67+
"/p:NoNuGet=true",
68+
"/verbosity:%s" % VERBOSITY,
69+
]
70+
71+
self.announce("Building: %s" % " ".join(cmd))
72+
check_call(" ".join(cmd) + " /t:Clean", shell=True)
73+
check_call(" ".join(cmd) + " /t:Build", shell=True)
74+
75+
if DEVTOOLS == "Mono":
76+
self._build_monoclr(ext)
77+
78+
79+
def _build_monoclr(self, ext):
80+
mono_libs = check_output("pkg-config --libs mono-2", shell=True)
81+
mono_cflags = check_output("pkg-config --cflags mono-2", shell=True)
82+
glib_libs = check_output("pkg-config --libs glib-2.0", shell=True)
83+
glib_cflags = check_output("pkg-config --cflags glib-2.0", shell=True)
84+
cflags = mono_cflags.strip() + " " + glib_cflags.strip()
85+
libs = mono_libs.strip() + " " + glib_libs.strip()
86+
87+
# build the clr python module
88+
setup(name="monoclr",
89+
ext_modules=[
90+
Extension("clr",
91+
sources=[
92+
"src/monoclr/pynetinit.c",
93+
"src/monoclr/clrmod.c"
94+
],
95+
extra_compile_args=cflags.split(" "),
96+
extra_link_args=libs.split(" "),
97+
)]
98+
)
99+
100+
# build the clr python executable
101+
sources = [
102+
"src/monoclr/pynetinit.c",
103+
"src/monoclr/python.c",
104+
]
105+
106+
macros = ext.define_macros[:]
107+
for undef in ext.undef_macros:
108+
macros.append((undef,))
109+
110+
objects = self.compiler.compile(sources,
111+
output_dir=self.build_temp,
112+
macros=macros,
113+
include_dirs=ext.include_dirs,
114+
debug=self.debug,
115+
extra_postargs=cflags.split(" "),
116+
depends=ext.depends)
117+
118+
output_dir = os.path.dirname(self.get_ext_fullpath(ext.name))
119+
py_libs = get_config_vars("BLDLIBRARY")[0]
120+
libs += " " + py_libs
121+
122+
self.compiler.link_executable(objects,
123+
"npython",
124+
output_dir=output_dir,
125+
libraries=self.get_libraries(ext),
126+
library_dirs=ext.library_dirs,
127+
runtime_library_dirs=ext.runtime_library_dirs,
128+
extra_postargs=libs.split(" "),
129+
debug=self.debug)
130+
131+
132+
if __name__ == "__main__":
133+
setup(name="pythonnet",
134+
ext_modules=[
135+
Extension("clr", sources=[])
136+
],
137+
cmdclass = {
138+
"build_ext" : PythonNET_BuildExt
139+
}
140+
)
141+

pythonnet/src/clrmodule/clrmodule.csproj

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
1515
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
16+
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)</PythonBuildDir>
1617
<RestorePackages>true</RestorePackages>
1718
</PropertyGroup>
1819
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|x86'">
1920
<DebugSymbols>true</DebugSymbols>
2021
<OutputPath>bin\x86\DebugMono\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
2223
<DebugType>full</DebugType>
2324
<PlatformTarget>x86</PlatformTarget>
2425
<ErrorReport>prompt</ErrorReport>
@@ -29,7 +30,7 @@
2930
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugMono|x64'">
3031
<DebugSymbols>true</DebugSymbols>
3132
<OutputPath>bin\x64\DebugMono\</OutputPath>
32-
<DefineConstants>DEBUG;TRACE</DefineConstants>
33+
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
3334
<DebugType>full</DebugType>
3435
<PlatformTarget>x64</PlatformTarget>
3536
<ErrorReport>prompt</ErrorReport>
@@ -39,8 +40,7 @@
3940
</PropertyGroup>
4041
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseMono|x86'">
4142
<OutputPath>bin\x86\ReleaseMono\</OutputPath>
42-
<DefineConstants>
43-
</DefineConstants>
43+
<DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants>
4444
<Optimize>true</Optimize>
4545
<DebugType>pdbonly</DebugType>
4646
<PlatformTarget>x86</PlatformTarget>
@@ -51,8 +51,7 @@
5151
</PropertyGroup>
5252
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseMono|x64'">
5353
<OutputPath>bin\x64\ReleaseMono\</OutputPath>
54-
<DefineConstants>
55-
</DefineConstants>
54+
<DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants>
5655
<Optimize>true</Optimize>
5756
<DebugType>pdbonly</DebugType>
5857
<PlatformTarget>x64</PlatformTarget>
@@ -64,7 +63,7 @@
6463
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugWin|x86'">
6564
<DebugSymbols>true</DebugSymbols>
6665
<OutputPath>bin\x86\DebugWin\</OutputPath>
67-
<DefineConstants>TRACE;DEBUG;DEBUG_PRINT</DefineConstants>
66+
<DefineConstants Condition="'$(DefineConstants)' == ''">TRACE;DEBUG;DEBUG_PRINT</DefineConstants>
6867
<DebugType>full</DebugType>
6968
<PlatformTarget>x86</PlatformTarget>
7069
<ErrorReport>prompt</ErrorReport>
@@ -75,7 +74,7 @@
7574
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|x64'">
7675
<DebugSymbols>true</DebugSymbols>
7776
<OutputPath>bin\x64\DebugWin\</OutputPath>
78-
<DefineConstants>DEBUG;TRACE</DefineConstants>
77+
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
7978
<DebugType>full</DebugType>
8079
<PlatformTarget>x64</PlatformTarget>
8180
<ErrorReport>prompt</ErrorReport>
@@ -85,8 +84,7 @@
8584
</PropertyGroup>
8685
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|x86'">
8786
<OutputPath>bin\x86\ReleaseWin\</OutputPath>
88-
<DefineConstants>
89-
</DefineConstants>
87+
<DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants>
9088
<Optimize>true</Optimize>
9189
<DebugType>pdbonly</DebugType>
9290
<PlatformTarget>x86</PlatformTarget>
@@ -97,8 +95,7 @@
9795
</PropertyGroup>
9896
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|x64'">
9997
<OutputPath>bin\x64\ReleaseWin\</OutputPath>
100-
<DefineConstants>
101-
</DefineConstants>
98+
<DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants>
10299
<Optimize>true</Optimize>
103100
<DebugType>pdbonly</DebugType>
104101
<PlatformTarget>x64</PlatformTarget>
@@ -122,20 +119,9 @@
122119
<None Include="packages.config" />
123120
</ItemGroup>
124121
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
125-
<PropertyGroup>
126-
<PreBuildEvent>del "$(SolutionDir)clr.pyd"</PreBuildEvent>
127-
</PropertyGroup>
128-
<PropertyGroup>
129-
<PostBuildEvent>move "$(TargetPath)" "$(TargetDir)clr.pyd"
130-
copy "$(TargetDir)clr.pyd" "$(SolutionDir)"</PostBuildEvent>
131-
</PropertyGroup>
132-
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
133-
<Import Project="../../packages/UnmanagedExports.1.2.3-Beta/tools/RGiesecke.DllExport.targets" Condition="Exists('../../packages/UnmanagedExports.1.2.3-Beta/tools/RGiesecke.DllExport.targets')" />
134-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
135-
Other similar extension points exist, see Microsoft.Common.targets.
136-
<Target Name="BeforeBuild">
137-
</Target>
138-
<Target Name="AfterBuild">
122+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="'$(NoNuGet)' != 'true' And Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
123+
<Import Project="..\..\packages\UnmanagedExports.1.2.3-Beta\tools\RGiesecke.DllExport.targets" Condition="Exists('..\..\packages\UnmanagedExports.1.2.3-Beta\tools\RGiesecke.DllExport.targets')"/>
124+
<Target Name="AfterBuild" DependsOnTargets="RGieseckeDllExport">
125+
<Copy SourceFiles="$(TargetPath)" DestinationFiles="$(PythonBuildDir)\clr.pyd" />
139126
</Target>
140-
-->
141127
</Project>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy