diff --git a/pyext/Makefile.am b/pyext/Makefile.am new file mode 100755 index 0000000..6464cb9 --- /dev/null +++ b/pyext/Makefile.am @@ -0,0 +1,29 @@ +## Process this file with automake to produce Makefile.in + +if HAVE_SWIG +if HAVE_PYTHON +if ENABLE_PYTHON_BINDING + +SWIG_INTERFACE = ctatools.i +BUILT_SOURCES = ctatools_wrap.cpp ctatools.py +CLEANFILES = ctatools_wrap.cpp ctatools.py + +all-local: ctatools_wrap.cpp ctatools.py + $(PYTHON) setup.py build + +install-exec-local: + $(PYTHON) setup.py install --prefix=$(prefix) + +clean-local: + rm -rf build + +ctatools_wrap.cpp ctatools.py: $(SWIG_INTERFACE) + $(SWIG) -c++ -python -Wall -includeall -I$(prefix)/share/gammalib/swig -o ctatools_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 ctatools_wrap.cpp; \ + fi + +endif # ENABLE_PYTHON_BINDING +endif # HAVE_PYTHON +endif # HAVE_SWIG diff --git a/pyext/ctatools.i b/pyext/ctatools.i new file mode 100755 index 0000000..d0f3124 --- /dev/null +++ b/pyext/ctatools.i @@ -0,0 +1,23 @@ +/*************************************************************************** + * ctatools - SWIG file * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * ----------------------------------------------------------------------- * + * Usage: * + * swig -c++ -python -Wall -includeall ctatools.i * + ***************************************************************************/ +%module ctatools + +/***********************************************************************//** + * @brief Include all CTA tools + ***************************************************************************/ +#include "ctselect.i" +#include "ctbin.i" +#include "ctlike.i" diff --git a/pyext/ctbin.i b/pyext/ctbin.i new file mode 100644 index 0000000..e3370e1 --- /dev/null +++ b/pyext/ctbin.i @@ -0,0 +1,47 @@ +/*************************************************************************** + * ctbin - CTA data binning tool * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file ctbin.i + * @brief CTA data binning tool SWIG definition + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "ctbin.hpp" +%} +%include gammalib.i + + +/***********************************************************************//** + * @class ctbin + * + * @brief CTA data binning tool SWIG interface defintion. + ***************************************************************************/ +class ctbin : public GApplication { +public: + // Constructors and destructors + ctbin(void) : GApplication(CTBIN_NAME, CTBIN_VERSION) { return; } + + // Methods + int run(void); +}; + + +/***********************************************************************//** + * @brief CTA data binning tool SWIG extension + ***************************************************************************/ +%extend ctbin { + ctbin copy() { + return (*self); + } +} diff --git a/pyext/ctselect.i b/pyext/ctselect.i new file mode 100644 index 0000000..72c9202 --- /dev/null +++ b/pyext/ctselect.i @@ -0,0 +1,47 @@ +/*************************************************************************** + * ctselect - CTA data selection tool * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file ctselect.i + * @brief CTA data selection tool SWIG definition + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "ctselect.hpp" +%} +%include gammalib.i + + +/***********************************************************************//** + * @class ctselect + * + * @brief CTA data selection tool SWIG interface defintion. + ***************************************************************************/ +class ctselect : public GApplication { +public: + // Constructors and destructors + ctselect(void) : GApplication(CTSELECT_NAME, CTSELECT_VERSION) { return; } + + // Methods + int run(void); +}; + + +/***********************************************************************//** + * @brief CTA data selection tool SWIG extension + ***************************************************************************/ +%extend ctselect { + ctselect copy() { + return (*self); + } +} diff --git a/pyext/setup.py.in b/pyext/setup.py.in new file mode 100644 index 0000000..5a891ed --- /dev/null +++ b/pyext/setup.py.in @@ -0,0 +1,14 @@ +from distutils.core import setup, Extension +setup(name='@PACKAGE_NAME@', + version='@PACKAGE_VERSION@', + description='ctatools Python binding', + author='Jurgen Knodlseder', + author_email='@PACKAGE_BUGREPORT@', + url='http://gammalib.sourceforge.net/', + py_modules=['ctatools'], + ext_modules=[Extension('_ctatools', ['ctatools_wrap.cpp'], + include_dirs=['@prefix@/include/gammalib', '@top_srcdir@/src/ctbin', '@top_srcdir@/src/ctselect'], + library_dirs=['@prefix@/lib'], + libraries=['ctatools','gamma','cfitsio'], + runtime_library_dirs=['@prefix@/lib'])], + )