forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·61 lines (51 loc) · 2.21 KB
/
setup.py
File metadata and controls
executable file
·61 lines (51 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# ==========================================================================
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# ==========================================================================
"""Setup file for Mono clr.so
Author: Christian Heimes <christian(at)cheimes(dot)de>
"""
import os
import sys
from distutils.core import setup
from distutils.core import Extension
import subprocess
VERSION = "%i.%i" % sys.version_info[:2]
def pkgconfig(*packages, **kw):
"""From http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502261
XXX cmd = "export PKG_CONFIG_PATH=/opt/mono-2.8/lib/pkgconfig:... early 2011
"""
flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
cmd = "export PKG_CONFIG_PATH=/lib/pkgconfig; pkg-config --libs --cflags %s" % ' '.join(packages)
popen = subprocess.Popen(cmd, shell=True, close_fds=True, stdout=subprocess.PIPE)
popen.wait()
if popen.returncode != 0:
raise RuntimeError("An error has occured")
output = popen.stdout.read().strip()
for token in output.split():
if flag_map.has_key(token[:2]):
kw.setdefault(flag_map.get(token[:2]), []).append(token[2:])
else: # throw others to extra_link_args
kw.setdefault('extra_link_args', []).append(token)
for k, v in kw.iteritems(): # remove duplicated
kw[k] = list(set(v))
return kw
#argsDict['include_dirs'] += ['/opt/mono-2.8/include','/include:usr/include','/usr/include/glib-2.0','/usr/lib/glib-2.0/include']
argsDict = pkgconfig('glib-2.0', 'mono-2')
clr = Extension('clr',
['src/monoclr/clrmod.c', 'src/monoclr/pynetinit.c'],
depends=['src/monoclr/pynetclr.h'],
**argsDict
)
extensions = []
if os.name == "posix":
extensions.append(clr)
setup(name="clr",
ext_modules = extensions,
scripts = ["src/monoclr/clrpython%s" % VERSION],
)