8000 Contributions by VIKAS DHIMAN - - Thanks, Vikas! · pythonnet/pythonnet-rawsvnmig@3bf6ab4 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jun 4, 2019. It is now read-only.

Commit 3bf6ab4

Browse files
author
Barton Cline
committed
Contributions by VIKAS DHIMAN - - Thanks, Vikas!
My test machine is Ubuntu 10.10. My Mono install is in /opt/mono-2.8 (.2, as I recall) oldmodule.il stores the original clrmodule.il and is copied there on Windows (untested by me) clrmodule.pp.il is input to gcc pre-processor only with clrmodule.il as the output. The makefile decides which to use base on host environment. I added glib.h to pynetclr.h and moved Python.h to first to eliminate some warnings.
1 parent 25bbdaf commit 3bf6ab4

File tree

6 files changed

+588
-10
lines changed

6 files changed

+588
-10
lines changed

pythonnet/Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ UCS ?= $(shell $(PYTHON) -c "import sys; \
1616
SITEPACKAGES = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; \
1717
print get_python_lib(plat_specific=1, standard_lib=0)")
1818
INSTALL=/usr/bin/install -m644
19+
# Contributed by VIKAS DHIMAN - - Thanks, Vikas!
20+
ARCH_FULL = $(shell uname -m)
21+
ifneq (, $(findstring 86, $(ARCH_FULL)))
22+
ARCH = x86
23+
else
24+
ARCH = x64
25+
endif
1926

2027
ifeq ($(origin WINDIR), undefined)
2128
RUNNER = mono
@@ -70,6 +77,15 @@ Python.Runtime.dll: $(RUNTIME_CS)
7077
$(CSC) /unsafe /target:library \
7178
$(RUNTIME_REF) /out:../../Python.Runtime.dll /recurse:*.cs
7279

80+
# Contributed by VIKAS DHIMAN - - Thanks, Vikas!
81+
src/runtime/clrmodule.il: src/runtime/clrmodule.pp.il
82+
ifeq ($(origin WINDIR), undefined)
83+
cd "$(BASEDIR)/src/runtime";\
84+
$(CPP) -C -P -x c++ -I $(ARCH) clrmodule.pp.il -o clrmodule.il
85+
else
86+
cd "$(BASEDIR)/src/runtime";\
87+
cp oldmodule.il clrmodule.il
88+
endif
7389

7490
clr.pyd: Python.Runtime.dll src/runtime/clrmodule.il
7591
$(ILASM) /nologo /dll /quiet /output=clr.pyd \
@@ -106,7 +122,7 @@ realclean: clean
106122 8000
rm -f Python*.il Python*.il2 Python*.res
107123
rm -rf build/
108124
cd src/console; rm -rf bin; rm -rf obj; cd ../..;
109-
cd src/runtime; rm -rf bin; rm -rf obj; cd ../..;
125+
cd src/runtime; rm -rf bin; rm -rf obj; rm clrmodule.il; cd ../..;
110126
cd src/testing; rm -rf bin; rm -rf obj; cd ../..;
111127
cd src/embed_tests; rm -rf bin; rm -rf obj; rm -f TestResult.xml; cd ../..;
112128
cd src/monoclr; make clean; cd ../..

pythonnet/setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def pkgconfig(*packages, **kw):
2424
"""From http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502261
2525
"""
2626
flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
27-
cmd = "pkg-config --libs --cflags %s" % ' '.join(packages)
27+
cmd = "export PKG_CONFIG_PATH=/opt/mono-2.8/lib/pkgconfig:/lib/pkgconfig; pkg-config --libs --cflags %s" % ' '.join(packages)
2828
popen = subprocess.Popen(cmd, shell=True, close_fds=True, stdout=subprocess.PIPE)
2929
popen.wait()
3030
if popen.returncode != 0:
@@ -41,11 +41,13 @@ def pkgconfig(*packages, **kw):
4141
kw[k] = list(set(v))
4242

4343
return kw
44+
argsDict = pkgconfig('mono-2')
45+
argsDict['include_dirs'] += ['/opt/mono-2.8/include','/include:usr/include','/usr/include/glib-2.0','/usr/lib/glib-2.0/include']
4446

4547
clr = Extension('clr',
4648
['src/monoclr/clrmod.c', 'src/monoclr/pynetinit.c'],
4749
depends=['src/monoclr/pynetclr.h'],
48-
**pkgconfig('mono')
50+
**argsDict
4951
)
5052

5153
extensions = []
@@ -55,4 +57,4 @@ def pkgconfig(*packages, **kw):
5557
setup(name="clr",
5658
ext_modules = extensions,
5759
scripts = ["src/monoclr/clrpython%s" % VERSION],
58-
)
60+
)

pythonnet/src/monoclr/Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
# Author: Christian Heimes
22

3-
PYTHON = python2.5
3+
PYTHON = python
44
BASENAME = $(shell $(PYTHON) -c "import sys; print 'python%i.%i' % sys.version_info[:2]")
55
GCC = gcc
66

7+
ifeq ($(origin WINDIR), undefined)
8+
DLL_OR_SO = "-shared"
9+
else
10+
DLL_OR_SO = "-dynamiclib"
11+
endif
12+
13+
714
PY_LIBS = $(shell $(PYTHON) -c "from distutils.sysconfig import get_config_vars; \
8-
print get_config_vars('BLDLIBRARY')[0]") -lpython
15+
print get_config_vars('BLDLIBRARY')[0]") #-lpython
916
PY_CFLAGS = -I$(shell $(PYTHON) -c "from distutils.sysconfig import get_config_vars; \
1017
print get_config_vars('CFLAGS')[0] + ' -I' + get_config_vars('CONFINCLUDEPY')[0]")
1118

12-
MONO_LIBS = $(shell pkg-config --libs mono)
13-
MONO_CFLAGS = $(shell pkg-config --cflags mono)
19+
MONO_LIBS = $(shell pkg-config --libs mono) # Was --libs mono
20+
MONO_CFLAGS = $(shell pkg-config --cflags mono) # Was --cflags mono
1421

1522
LIBS = $(MONO_LIBS) $(PY_LIBS)
1623
CFLAGS = $(MONO_CFLAGS) $(PY_CFLAGS)
@@ -30,7 +37,7 @@ $(BASENAME): python.c
3037
$(GCC) $(PY_CFLAGS) $(PY_LIBS) python.c -o $(BASENAME)
3138

3239
clr.so: clrmod.o pynetinit.o
33-
$(GCC) $(LIBS) -dynamiclib pynetinit.o clrmod.o -o clr.so
40+
$(GCC) $(LIBS) $(DLL_OR_SO) pynetinit.o clrmod.o -o clr.so
3441

3542
clr$(BASENAME): clrpython.o pynetinit.o
3643
$(GCC) $(LIBS) clrpython.o pynetinit.o -o clr$(BASENAME)

pythonnet/src/monoclr/pynetclr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
#ifndef PYNET_CLR_H
1313
#define PYNET_CLR_H
1414

15+
#include <Python.h>
1516
#include <mono/jit/jit.h>
1617
#include <mono/metadata/environment.h>
1718
#include <mono/metadata/mono-config.h>
1819
#include <mono/metadata/debug-helpers.h>
1920
#include <mono/metadata/assembly.h>
20-
#include <Python.h>
21+
#include <glib.h>
2122

2223
#define MONO_VERSION "v2.0.50727"
2324
#define MONO_DOMAIN "Python.Runtime"

0 commit comments

Comments
 (0)
0