setup.py include directories patch.

23 views
Skip to first unread message

Daniel

unread,
Mar 14, 2010, 7:34:57 AM3/14/10
to llvm-py: Python Bindings for LLVM
Hi,

I have a patch which solves a problem I encountered. The problem is
that in setup.py it uses 'llvm-config --includedir' to find the
include directory. AFAIK this is fine if you've installed llvm, but if
has just been built and not installed, then there are two include
directories. The patch uses 'llvm-config --cflags' to find both
include directories.

Daniel

Index: setup.py
===================================================================
--- setup.py (revision 85)
+++ setup.py (working copy)
@@ -75,7 +75,7 @@

def call_setup(llvm_config):

- incdir = _run(llvm_config + ' --includedir')
+ cflags = _run(llvm_config + ' --cflags')
libdir = _run(llvm_config + ' --libdir')
ldflags = _run(llvm_config + ' --ldflags')
libs_core, objs_core = get_libs_and_objs(llvm_config,
@@ -87,7 +87,14 @@
std_libs = [ 'pthread', 'm', 'stdc++' ]
if not ("openbsd" in sys.platform or "freebsd" in sys.platform):
std_libs.append("dl")
-
+
+ include = []
+ cflags = cflags.split()
+
+ for flag in cflags:
+ if flag[:2] == '-I':
+ include.append(flag[2:])
+
ext_core = Extension(
'llvm._core',
['llvm/_core.c', 'llvm/wrap.c', 'llvm/extra.cpp'],
@@ -95,7 +102,7 @@
('__STDC_CONSTANT_MACROS', None),
('__STDC_LIMIT_MACROS', None),
('_GNU_SOURCE', None)],
- include_dirs = [incdir],
+ include_dirs = include,
library_dirs = [libdir],
libraries = std_libs + libs_core,
extra_objects = objs_core,

Reply all
Reply to author
Forward
0 new messages