From e11f1c3f5ba24ce2059e3d683b4645e6b45a12d6 Mon Sep 17 00:00:00 2001 From: Aren Olson Date: Wed, 10 Jun 2009 14:11:28 +0000 Subject: [PATCH] make setup.py respect pkg-config if available --- experimental/python-libburn/setup.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/experimental/python-libburn/setup.py b/experimental/python-libburn/setup.py index ecbe2ed1..a9467469 100644 --- a/experimental/python-libburn/setup.py +++ b/experimental/python-libburn/setup.py @@ -2,14 +2,30 @@ from distutils.core import setup, Extension +import os +modname='libburn-1' + +libs = ['burn'] +includes = ['/usr/include/libburn'] + +if os.system('pkg-config --exists '+modname+' 2> /dev/null') == 0: + pkgcfg = os.popen('pkg-config --cflags-only-I '+modname) + includes = pkgcfg.readline().strip() + includes = includes[2:].split(' -I') + pkgcfg.close() + + pkgcfg = os.popen('pkg-config --libs-only-l '+modname) + libs = pkgcfg.readline().strip() + libs = libs[2:].split(' -l') + pkgcfg.close() + setup(name = "python-libburn", version = "0.0.1", description = "Python bindings to libburn", ext_modules = [Extension("pyburn", ["pyburn.cpp"], - libraries=[':libburn.so'], - include_dirs=['/usr/include/libburn'], # FIXME: make this more - # portable + libraries=libs, + include_dirs=includes, )] )