diff --git a/.gitignore b/.gitignore index d1de7f9..d8a9eab 100644 --- a/.gitignore +++ b/.gitignore @@ -44,8 +44,8 @@ doc/man src/ctools-setup pyext/build/ pyext/setup.py -pyext/ctools/ctools.py -pyext/ctools/ctools_wrap.cpp +pyext/ctools/tools.py +pyext/ctools/tools_wrap.cpp src/ctbin/ctbin src/ctlike/ctlike src/cttsmap/cttsmap diff --git a/configure.ac b/configure.ac index ac683df..5902825 100644 --- a/configure.ac +++ b/configure.ac @@ -522,8 +522,8 @@ AC_C_INLINE ############################################################################# # Checks if Python bindings are to be build # # ------------------------------------------------------------------------- # -# Python binding requires Python and either the files ctools_wrap.cpp and # -# ctools.py or swig to create these files. The following conditionals are # +# Python binding requires Python and either the files tools_wrap.cpp and # +# tools.py or swig to create these files. The following conditionals are # # set: # # WITH_PYTHON - Python bindings will be built # # HAVE_SWIG - swig is available # @@ -628,9 +628,9 @@ else has_swig="yes" fi - # Do we have wrappers (ctools_wrap.cpp and ctools.py)? + # Do we have wrappers (tools_wrap.cpp and tools.py)? has_wrappers="yes" - AC_CHECK_FILES([pyext/ctools/ctools_wrap.cpp pyext/ctools/ctools.py],, + AC_CHECK_FILES([pyext/ctools/tools_wrap.cpp pyext/ctools/tools.py],, [has_wrappers="no"]) if test "x$has_wrappers" = "xno"; then AC_MSG_WARN([Python wrapper missing. Requires swig for wrapper generation.]) @@ -669,9 +669,9 @@ if test "x$enable_python" = "xyes"; then else if test "x$has_python_wrap" = "xno" -a "x$has_swig" = "xno"; then - AC_MSG_WARN([Neither pyext/ctools/ctools_wrap.cpp and pyext/ctools/ctools.py nor swig has not been found]) + AC_MSG_WARN([Neither pyext/ctools/tools_wrap.cpp and pyext/ctools/tools.py nor swig has not been found]) AC_MSG_WARN([Python binding for ctools cannot be built]) - AC_MSG_WARN([Either use a ctools distribution with ctools_wrap.cpp and ctools.py shipped or install swig on your system]) + AC_MSG_WARN([Either use a ctools distribution with tools_wrap.cpp and tools.py shipped or install swig on your system]) AC_MSG_WARN([swig can be obtained from http://www.swig.org/]) fi fi diff --git a/pyext/Makefile.am b/pyext/Makefile.am index 9b2d2ce..4d6ccc8 100755 --- a/pyext/Makefile.am +++ b/pyext/Makefile.am @@ -1,7 +1,7 @@ ############################################################################# # Makefile for ctools Python extension module # # ------------------------------------------------------------------------- # -# Copyright (C) 2011-2012 Juergen Knoedlseder # +# Copyright (C) 2011-2014 Juergen Knoedlseder # # ------------------------------------------------------------------------- # # # # This program is free software: you can redistribute it and/or modify # @@ -30,7 +30,7 @@ if WITH_PYTHON # Set SWIG interface filename -SWIG_INTERFACE = ctools/ctools.i +SWIG_INTERFACE = ctools/tools.i # Dependencies. Obtain the list of dependencies by executing ls. DEPFILES = $(shell ls *.Pi 2> /dev/null) @@ -39,7 +39,7 @@ include $(DEPFILES) # Define the targets that should be built before anything else. # These are honored by 'make all', 'make check' and 'make install'. if HAVE_SWIG - BUILT_SOURCES = ctools/ctools_wrap.cpp ctools/ctools.py + BUILT_SOURCES = ctools/tools_wrap.cpp ctools/tools.py endif # Set files to be removed in clean. We remove only the SWIG interface files @@ -59,21 +59,21 @@ all-local: build # of this specific directory. So we build one instance for checking, the other # for installation. If we could get the name built by distutils we could avoid # this. -build: ctools/ctools_wrap.cpp ctools/ctools.py +build: ctools/tools_wrap.cpp ctools/tools.py $(PYTHON) setup.py build install-exec-local: $(PYTHON) setup.py install --prefix=$(prefix) clean-local: - rm -rf build _ctools.so + rm -rf build _tools.so # Rule for building Python wrappers using SWIG. if HAVE_SWIG -ctools/ctools.py: ctools/ctools_wrap.cpp -ctools/ctools_wrap.cpp: $(SWIG_INTERFACE) - if $(SWIGCOMPILE) -MMD -MF "ctools.Tpi" -o ctools/ctools_wrap.cpp $<; \ - then mv -f "ctools.Tpi" "ctools.Pi"; else rm -f "ctools.Tpi"; exit 1; fi +ctools/tools.py: ctools/tools_wrap.cpp +ctools/tools_wrap.cpp: $(SWIG_INTERFACE) + if $(SWIGCOMPILE) -MMD -MF "tools.Tpi" -o ctools/tools_wrap.cpp $<; \ + then mv -f "tools.Tpi" "tools.Pi"; else rm -f "tools.Tpi"; exit 1; fi endif # HAVE_SWIG endif # WITH_PYTHON diff --git a/pyext/ctools/__init__.py b/pyext/ctools/__init__.py index 1d6af6e..c9d32d9 100644 --- a/pyext/ctools/__init__.py +++ b/pyext/ctools/__init__.py @@ -1,9 +1,16 @@ -from .ctools import * +# Import sub modules +from .tools import * import obsutils +# Remove swig register stuff bad_entries = [entry for entry in list(locals()) if entry.endswith('_swigregister')] for entry in bad_entries: del locals()[entry] -del gammalib + +# Clean-up +del tools del ctools +del gammalib +del bad_entries +del entry \ No newline at end of file diff --git a/pyext/ctools/ctools.i b/pyext/ctools/tools.i index f84bd71..7d75cf1 100755 --- a/pyext/ctools/ctools.i +++ b/pyext/ctools/tools.i @@ -1,5 +1,5 @@ /*************************************************************************** - * ctools - SWIG file * + * ctools - SWIG file * * ----------------------------------------------------------------------- * * copyright (C) 2010-2014 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * @@ -19,14 +19,14 @@ * * * ----------------------------------------------------------------------- * * Usage: * - * swig -c++ -python -Wall ctools.i * + * swig -c++ -python -Wall tools.i * ***************************************************************************/ /** - * @file ctools.i + * @file tools.i * @brief ctools SWIG file * @author Juergen Knoedlseder */ -%module ctools +%module tools %feature("autodoc", "1"); /* __ Headers needed for compilation _____________________________________ */ diff --git a/pyext/setup.py.in b/pyext/setup.py.in index cafbbf8..e743ec1 100644 --- a/pyext/setup.py.in +++ b/pyext/setup.py.in @@ -1,7 +1,7 @@ ############################################################################# # Disutils setup file for ctools Python extension module # # ------------------------------------------------------------------------- # -# Copyright (C) 2011-2012 Juergen Knoedlseder # +# Copyright (C) 2011-2014 Juergen Knoedlseder # # ------------------------------------------------------------------------- # # # # This program is free software: you can redistribute it and/or modify # @@ -18,7 +18,6 @@ # along with this program. If not, see . # # # ############################################################################# - from distutils.core import setup, Extension from distutils import sysconfig import glob @@ -122,8 +121,8 @@ setup(name='@PACKAGE_NAME@', author='Juergen Knoedlseder', author_email='@PACKAGE_BUGREPORT@', url='http://gammalib.sourceforge.net/', - py_modules=['ctools.ctools', 'ctools.obsutils'], - ext_modules=[Extension('ctools._ctools', ['ctools/ctools_wrap.cpp'], + py_modules=['ctools.tools', 'ctools.obsutils'], + ext_modules=[Extension('ctools._tools', ['ctools/tools_wrap.cpp'], include_dirs=include_dirs, library_dirs=library_dirs, libraries=libraries,