| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 98264a3 commit 5300343
12 files changed
| Original file line number | Diff line number | Diff 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 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,18 +89,10 @@ Global | |||
| 89 | 89 | {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x64.Build.0 = Release|x64 | |
| 90 | 90 | {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.ActiveCfg = Release|x86 | |
| 91 | 91 | {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 | ||
| 96 | 92 | {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.ActiveCfg = DebugWin|x64 | |
| 97 | 93 | {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.Build.0 = DebugWin|x64 | |
| 98 | 94 | {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.ActiveCfg = DebugWin|x86 | |
| 99 | 95 | {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 | ||
| 104 | 96 | {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 | |
| 105 | 97 | {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 | |
| 106 | 98 | {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 | |
| Original file line number | Diff line number | Diff 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 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,12 +13,13 @@ | |||
| 13 | 13 | <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | |
| 14 | 14 | <FileAlignment>512</FileAlignment> | |
| 15 | 15 | <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | |
| 16 | + <PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)</PythonBuildDir> | ||
| 16 | 17 | <RestorePackages>true</RestorePackages> | |
| 17 | 18 | </PropertyGroup> | |
| 18 | 19 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|x86'"> | |
| 19 | 20 | <DebugSymbols>true</DebugSymbols> | |
| 20 | 21 | <OutputPath>bin\x86\DebugMono\</OutputPath> | |
| 21 | - <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
| 22 | + <DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants> | ||
| 22 | 23 | <DebugType>full</DebugType> | |
| 23 | 24 | <PlatformTarget>x86</PlatformTarget> | |
| 24 | 25 | <ErrorReport>prompt</ErrorReport> | |
@@ -29,7 +30,7 @@ | |||
| 29 | 30 | <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugMono|x64'"> | |
| 30 | 31 | <DebugSymbols>true</DebugSymbols> | |
| 31 | 32 | <OutputPath>bin\x64\DebugMono\</OutputPath> | |
| 32 | - <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
| 33 | + <DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants> | ||
| 33 | 34 | <DebugType>full</DebugType> | |
| 34 | 35 | <PlatformTarget>x64</PlatformTarget> | |
| 35 | 36 | <ErrorReport>prompt</ErrorReport> | |
@@ -39,8 +40,7 @@ | |||
| 39 | 40 | </PropertyGroup> | |
| 40 | 41 | <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseMono|x86'"> | |
| 41 | 42 | <OutputPath>bin\x86\ReleaseMono\</OutputPath> | |
| 42 | - <DefineConstants> | ||
| 43 | - </DefineConstants> | ||
| 43 | + <DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants> | ||
| 44 | 44 | <Optimize>true</Optimize> | |
| 45 | 45 | <DebugType>pdbonly</DebugType> | |
| 46 | 46 | <PlatformTarget>x86</PlatformTarget> | |
@@ -51,8 +51,7 @@ | |||
| 51 | 51 | </PropertyGroup> | |
| 52 | 52 | <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseMono|x64'"> | |
| 53 | 53 | <OutputPath>bin\x64\ReleaseMono\</OutputPath> | |
| 54 | - <DefineConstants> | ||
| 55 | - </DefineConstants> | ||
| 54 | + <DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants> | ||
| 56 | 55 | <Optimize>true</Optimize> | |
| 57 | 56 | <DebugType>pdbonly</DebugType> | |
| 58 | 57 | <PlatformTarget>x64</PlatformTarget> | |
@@ -64,7 +63,7 @@ | |||
| 64 | 63 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugWin|x86'"> | |
| 65 | 64 | <DebugSymbols>true</DebugSymbols> | |
| 66 | 65 | <OutputPath>bin\x86\DebugWin\</OutputPath> | |
| 67 | - <DefineConstants>TRACE;DEBUG;DEBUG_PRINT</DefineConstants> | ||
| 66 | + <DefineConstants Condition="'$(DefineConstants)' == ''">TRACE;DEBUG;DEBUG_PRINT</DefineConstants> | ||
| 68 | 67 | <DebugType>full</DebugType> | |
| 69 | 68 | <PlatformTarget>x86</PlatformTarget> | |
| 70 | 69 | <ErrorReport>prompt</ErrorReport> | |
@@ -75,7 +74,7 @@ | |||
| 75 | 74 | <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|x64'"> | |
| 76 | 75 | <DebugSymbols>true</DebugSymbols> | |
| 77 | 76 | <OutputPath>bin\x64\DebugWin\</OutputPath> | |
| 78 | - <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
| 77 | + <DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants> | ||
| 79 | 78 | <DebugType>full</DebugType> | |
| 80 | 79 | <PlatformTarget>x64</PlatformTarget> | |
| 81 | 80 | <ErrorReport>prompt</ErrorReport> | |
@@ -85,8 +84,7 @@ | |||
| 85 | 84 | </PropertyGroup> | |
| 86 | 85 | <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|x86'"> | |
| 87 | 86 | <OutputPath>bin\x86\ReleaseWin\</OutputPath> | |
| 88 | - <DefineConstants> | ||
| 89 | - </DefineConstants> | ||
| 87 | + <DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants> | ||
| 90 | 88 | <Optimize>true</Optimize> | |
| 91 | 89 | <DebugType>pdbonly</DebugType> | |
| 92 | 90 | <PlatformTarget>x86</PlatformTarget> | |
@@ -97,8 +95,7 @@ | |||
| 97 | 95 | </PropertyGroup> | |
| 98 | 96 | <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|x64'"> | |
| 99 | 97 | <OutputPath>bin\x64\ReleaseWin\</OutputPath> | |
| 100 | - <DefineConstants> | ||
| 101 | - </DefineConstants> | ||
| 98 | + <DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants> | ||
| 102 | 99 | <Optimize>true</Optimize> | |
| 103 | 100 | <DebugType>pdbonly</DebugType> | |
| 104 | 101 | <PlatformTarget>x64</PlatformTarget> | |
@@ -122,20 +119,9 @@ | |||
| 122 | 119 | <None Include="packages.config" /> | |
| 123 | 120 | </ItemGroup> | |
| 124 | 121 | <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" /> | ||
| 139 | 126 | </Target> | |
| 140 | - --> | ||
| 141 | 127 | </Project> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments