From 2f78058ef5dcc26947bd1bb76cfff0e5cef8317f Mon Sep 17 00:00:00 2001 From: knodlseder <> Date: Tue, 23 Nov 2010 13:21:46 +0000 Subject: [PATCH] optionally include instrument specific interfaces --- pyext/Makefile.am | 18 +++++++++++++----- pyext/setup.py.in | 22 +++++++++++++++++++--- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/pyext/Makefile.am b/pyext/Makefile.am index adb6d07..57eb7dc 100755 --- a/pyext/Makefile.am +++ b/pyext/Makefile.am @@ -1,7 +1,5 @@ ## Process this file with automake to produce Makefile.in -if HAVE_SWIG -if HAVE_PYTHON if ENABLE_PYTHON_BINDING SWIG_INTERFACE = gammalib.i @@ -9,6 +7,18 @@ BUILT_SOURCES = gammalib_wrap.cpp gammalib.py CLEANFILES = gammalib_wrap.cpp gammalib.py #EXTRA_DIST = runme.py +# Set instrument specific SWIG options (those will be catched in gammalib.i) +if WITH_INST_CTA + OPT_CTA = -DWITH_INST_CTA + INC_CTA = -I$(top_srcdir)/inst/cta/pyext +endif +if WITH_INST_LAT + OPT_LAT = -DWITH_INST_LAT + INC_LAT = -I$(top_srcdir)/inst/lat/pyext +endif +INC_INST = $(INC_CTA) $(INC_LAT) +OPT_INST = $(OPT_CTA) $(OPT_LAT) + all-local: gammalib_wrap.cpp gammalib.py $(PYTHON) setup.py build --build-platlib build @@ -19,12 +29,10 @@ clean-local: rm -rf build gammalib_wrap.cpp gammalib.py: $(SWIG_INTERFACE) - $(SWIG) -c++ -python -Wall -includeall -I$(top_srcdir)/src -o gammalib_wrap.cpp -outdir . $(srcdir)/$(SWIG_INTERFACE) + $(SWIG) -c++ -python -Wall -includeall -I$(top_srcdir)/src $(INC_INST) $(OPT_INST) -o gammalib_wrap.cpp -outdir . $(srcdir)/$(SWIG_INTERFACE) @if test "x`uname`" = "xCygwin"; then \ echo "WARNING: working around bug in SWIG on Windows/Cygwin platforms ONLY"; \ sed -i.bak -f $(srcdir)/fix_wrapper.sed gammalib_wrap.cpp; \ fi endif # ENABLE_PYTHON_BINDING -endif # HAVE_PYTHON -endif # HAVE_SWIG diff --git a/pyext/setup.py.in b/pyext/setup.py.in index 4d46f3a..3cc2a16 100644 --- a/pyext/setup.py.in +++ b/pyext/setup.py.in @@ -1,16 +1,32 @@ from distutils.core import setup, Extension import glob + +# Set default include directories and data files +include_dirs = ['@top_srcdir@/include'] +data_files = glob.glob('@top_srcdir@/pyext/*.i') + +# Add instrument specific include directories and data files +if '@WITH_INST_CTA_TRUE@' != '#': + print "Include CTA instrument interface in gammalib Python bindings." + include_dirs.append('@top_srcdir@/inst/cta/include') + data_files.extend(glob.glob('@top_srcdir@/inst/cta/pyext/*.i')) +if '@WITH_INST_LAT_TRUE@' != '#': + print "Include Fermi/LAT instrument interface in gammalib Python bindings." + include_dirs.append('@top_srcdir@/inst/lat/include') + data_files.extend(glob.glob('@top_srcdir@/inst/lat/pyext/*.i')) + +# Setup setup(name='@PACKAGE_NAME@', version='@PACKAGE_VERSION@', - description='gammalib Python binding', + description='gammalib Python bindings', author='Jurgen Knodlseder', author_email='@PACKAGE_BUGREPORT@', url='http://gammalib.sourceforge.net/', py_modules=['gammalib'], ext_modules=[Extension('_gammalib', ['gammalib_wrap.cpp'], - include_dirs=['@top_srcdir@/include', '@top_srcdir@/src', '@top_srcdir@/src/support', '@top_srcdir@/inst/cta/include', '@top_srcdir@/inst/lat/include'], + include_dirs=include_dirs, library_dirs=['../src/.libs'], libraries=['gamma','cfitsio'], runtime_library_dirs=['@prefix@/lib'])], - data_files=[('@prefix@/share/gammalib/swig', glob.glob('@top_srcdir@/pyext/*.i'))], + data_files=[('@prefix@/share/gammalib/swig', data_files)], ) -- libgit2 0.21.4