Commit 2f78058ef5dcc26947bd1bb76cfff0e5cef8317f

Authored by knodlseder
1 parent 413a0628

optionally include instrument specific interfaces

pyext/Makefile.am
1 ## Process this file with automake to produce Makefile.in 1 ## Process this file with automake to produce Makefile.in
2 2
3 -if HAVE_SWIG  
4 -if HAVE_PYTHON  
5 if ENABLE_PYTHON_BINDING 3 if ENABLE_PYTHON_BINDING
6 4
7 SWIG_INTERFACE = gammalib.i 5 SWIG_INTERFACE = gammalib.i
@@ -9,6 +7,18 @@ BUILT_SOURCES = gammalib_wrap.cpp gammalib.py @@ -9,6 +7,18 @@ BUILT_SOURCES = gammalib_wrap.cpp gammalib.py
9 CLEANFILES = gammalib_wrap.cpp gammalib.py 7 CLEANFILES = gammalib_wrap.cpp gammalib.py
10 #EXTRA_DIST = runme.py 8 #EXTRA_DIST = runme.py
11 9
  10 +# Set instrument specific SWIG options (those will be catched in gammalib.i)
  11 +if WITH_INST_CTA
  12 + OPT_CTA = -DWITH_INST_CTA
  13 + INC_CTA = -I$(top_srcdir)/inst/cta/pyext
  14 +endif
  15 +if WITH_INST_LAT
  16 + OPT_LAT = -DWITH_INST_LAT
  17 + INC_LAT = -I$(top_srcdir)/inst/lat/pyext
  18 +endif
  19 +INC_INST = $(INC_CTA) $(INC_LAT)
  20 +OPT_INST = $(OPT_CTA) $(OPT_LAT)
  21 +
12 all-local: gammalib_wrap.cpp gammalib.py 22 all-local: gammalib_wrap.cpp gammalib.py
13 $(PYTHON) setup.py build --build-platlib build 23 $(PYTHON) setup.py build --build-platlib build
14 24
@@ -19,12 +29,10 @@ clean-local: @@ -19,12 +29,10 @@ clean-local:
19 rm -rf build 29 rm -rf build
20 30
21 gammalib_wrap.cpp gammalib.py: $(SWIG_INTERFACE) 31 gammalib_wrap.cpp gammalib.py: $(SWIG_INTERFACE)
22 - $(SWIG) -c++ -python -Wall -includeall -I$(top_srcdir)/src -o gammalib_wrap.cpp -outdir . $(srcdir)/$(SWIG_INTERFACE) 32 + $(SWIG) -c++ -python -Wall -includeall -I$(top_srcdir)/src $(INC_INST) $(OPT_INST) -o gammalib_wrap.cpp -outdir . $(srcdir)/$(SWIG_INTERFACE)
23 @if test "x`uname`" = "xCygwin"; then \ 33 @if test "x`uname`" = "xCygwin"; then \
24 echo "WARNING: working around bug in SWIG on Windows/Cygwin platforms ONLY"; \ 34 echo "WARNING: working around bug in SWIG on Windows/Cygwin platforms ONLY"; \
25 sed -i.bak -f $(srcdir)/fix_wrapper.sed gammalib_wrap.cpp; \ 35 sed -i.bak -f $(srcdir)/fix_wrapper.sed gammalib_wrap.cpp; \
26 fi 36 fi
27 37
28 endif # ENABLE_PYTHON_BINDING 38 endif # ENABLE_PYTHON_BINDING
29 -endif # HAVE_PYTHON  
30 -endif # HAVE_SWIG  
pyext/setup.py.in
1 from distutils.core import setup, Extension 1 from distutils.core import setup, Extension
2 import glob 2 import glob
  3 +
  4 +# Set default include directories and data files
  5 +include_dirs = ['@top_srcdir@/include']
  6 +data_files = glob.glob('@top_srcdir@/pyext/*.i')
  7 +
  8 +# Add instrument specific include directories and data files
  9 +if '@WITH_INST_CTA_TRUE@' != '#':
  10 + print "Include CTA instrument interface in gammalib Python bindings."
  11 + include_dirs.append('@top_srcdir@/inst/cta/include')
  12 + data_files.extend(glob.glob('@top_srcdir@/inst/cta/pyext/*.i'))
  13 +if '@WITH_INST_LAT_TRUE@' != '#':
  14 + print "Include Fermi/LAT instrument interface in gammalib Python bindings."
  15 + include_dirs.append('@top_srcdir@/inst/lat/include')
  16 + data_files.extend(glob.glob('@top_srcdir@/inst/lat/pyext/*.i'))
  17 +
  18 +# Setup
3 setup(name='@PACKAGE_NAME@', 19 setup(name='@PACKAGE_NAME@',
4 version='@PACKAGE_VERSION@', 20 version='@PACKAGE_VERSION@',
5 - description='gammalib Python binding', 21 + description='gammalib Python bindings',
6 author='Jurgen Knodlseder', 22 author='Jurgen Knodlseder',
7 author_email='@PACKAGE_BUGREPORT@', 23 author_email='@PACKAGE_BUGREPORT@',
8 url='http://gammalib.sourceforge.net/', 24 url='http://gammalib.sourceforge.net/',
9 py_modules=['gammalib'], 25 py_modules=['gammalib'],
10 ext_modules=[Extension('_gammalib', ['gammalib_wrap.cpp'], 26 ext_modules=[Extension('_gammalib', ['gammalib_wrap.cpp'],
11 - include_dirs=['@top_srcdir@/include', '@top_srcdir@/src', '@top_srcdir@/src/support', '@top_srcdir@/inst/cta/include', '@top_srcdir@/inst/lat/include'], 27 + include_dirs=include_dirs,
12 library_dirs=['../src/.libs'], 28 library_dirs=['../src/.libs'],
13 libraries=['gamma','cfitsio'], 29 libraries=['gamma','cfitsio'],
14 runtime_library_dirs=['@prefix@/lib'])], 30 runtime_library_dirs=['@prefix@/lib'])],
15 - data_files=[('@prefix@/share/gammalib/swig', glob.glob('@top_srcdir@/pyext/*.i'))], 31 + data_files=[('@prefix@/share/gammalib/swig', data_files)],
16 ) 32 )