- Notifications
You must be signed in to change notification settings - Fork752
Build with mono on linux and add travis-ci settings#8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletions.travis.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
8 changes: 0 additions & 8 deletionspythonnet/pythonnet.sln
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletionspythonnet/setupmono.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
) | ||
40 changes: 13 additions & 27 deletionspythonnet/src/clrmodule/clrmodule.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.