[Debian-astro-commits] [gyoto] 153/221: Build system for the Python extension

Thibaut Jean-Claude Paumard thibaut at moszumanska.debian.org
Fri May 22 20:52:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

thibaut pushed a commit to branch master
in repository gyoto.

commit 455b96296e7974e0879c69fda662dd1c870dad8c
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date:   Wed Dec 17 17:10:51 2014 +0100

    Build system for the Python extension
---
 Makefile.in        |   28 +-
 aclocal.m4         |    1 +
 bin/Makefile.in    |   15 +-
 configure          |  740 +++++++++++++++++++++++-
 configure.ac       |   41 ++
 lib/Makefile.in    |   15 +-
 m4/python.m4       |  646 +++++++++++++++++++++
 python/Makefile.in |  201 +++++++
 python/PKG-INFO    |    6 +
 python/gyoto.i     |    1 +
 python/numpy.i     | 1579 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 python/setup.py.in |   45 ++
 12 files changed, 3311 insertions(+), 7 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 9a65eb8..9567fd1 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -90,8 +90,10 @@ DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
 	$(top_srcdir)/yorick/gyoto.info.in \
 	$(top_srcdir)/yorick/yorick1.in \
 	$(top_srcdir)/yorick/setpaths.i.in $(srcdir)/gyoto.in \
-	$(top_srcdir)/doc/doxyfile.in COPYING compile config.guess \
-	config.sub depcomp install-sh missing ltmain.sh
+	$(top_srcdir)/python/Makefile.in \
+	$(top_srcdir)/python/setup.py.in $(top_srcdir)/doc/doxyfile.in \
+	COPYING compile config.guess config.sub depcomp install-sh \
+	missing ltmain.sh
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
 	$(top_srcdir)/m4/ax_append_flag.m4 \
@@ -101,7 +103,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
 	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pkg.m4 \
-	$(top_srcdir)/configure.ac
+	$(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -110,7 +112,8 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = config.h $(top_builddir)/include/GyotoConfig.h
 CONFIG_CLEAN_FILES = doc/Makefile doc/user_guide/Makefile \
 	yorick/Makefile yorick/stdplug/Makefile yorick/gyoto.info \
-	yorick/yorick1 yorick/setpaths.i gyoto doc/doxyfile
+	yorick/yorick1 yorick/setpaths.i gyoto python/Makefile \
+	python/setup.py doc/doxyfile
 CONFIG_CLEAN_VPATH_FILES =
 AM_V_P = $(am__v_P_ at AM_V@)
 am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
@@ -297,6 +300,15 @@ POW_LIB = @POW_LIB@
 PTHREAD_CC = @PTHREAD_CC@
 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
 PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_ABI_FLAGS = @PYTHON_ABI_FLAGS@
+PYTHON_CFLAGS = @PYTHON_CFLAGS@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXTENSION_SUFFIX = @PYTHON_EXTENSION_SUFFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PREFIX = @PYTHON_PREFIX@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -309,6 +321,8 @@ UDUNITS_LDFLAGS = @UDUNITS_LDFLAGS@
 UDUNITS_LIBS = @UDUNITS_LIBS@
 VERSINFO = @VERSINFO@
 VERSION = @VERSION@
+VIRTUALENV = @VIRTUALENV@
+VIRTUALENV_FLAGS = @VIRTUALENV_FLAGS@
 XERCESCPPFLAGS = @XERCESCPPFLAGS@
 XERCESLDFLAGS = @XERCESLDFLAGS@
 XERCES_CFLAGS = @XERCES_CFLAGS@
@@ -363,10 +377,12 @@ pdfdir = @pdfdir@
 pkg_cflags = @pkg_cflags@
 pkg_libs = @pkg_libs@
 pkg_requires = @pkg_requires@
+pkgpythondir = @pkgpythondir@
 plugin_sfx = @plugin_sfx@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+pythondir = @pythondir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 sovers = @sovers@
@@ -459,6 +475,10 @@ yorick/setpaths.i: $(top_builddir)/config.status $(top_srcdir)/yorick/setpaths.i
 	cd $(top_builddir) && $(SHELL) ./config.status $@
 gyoto: $(top_builddir)/config.status $(srcdir)/gyoto.in
 	cd $(top_builddir) && $(SHELL) ./config.status $@
+python/Makefile: $(top_builddir)/config.status $(top_srcdir)/python/Makefile.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+python/setup.py: $(top_builddir)/config.status $(top_srcdir)/python/setup.py.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
 doc/doxyfile: $(top_builddir)/config.status $(top_srcdir)/doc/doxyfile.in
 	cd $(top_builddir) && $(SHELL) ./config.status $@
 
diff --git a/aclocal.m4 b/aclocal.m4
index 6dc027a..3fb170d 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1160,3 +1160,4 @@ m4_include([m4/ltsugar.m4])
 m4_include([m4/ltversion.m4])
 m4_include([m4/lt~obsolete.m4])
 m4_include([m4/pkg.m4])
+m4_include([m4/python.m4])
diff --git a/bin/Makefile.in b/bin/Makefile.in
index d4b8830..b01ee19 100644
--- a/bin/Makefile.in
+++ b/bin/Makefile.in
@@ -102,7 +102,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
 	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pkg.m4 \
-	$(top_srcdir)/configure.ac
+	$(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -311,6 +311,15 @@ POW_LIB = @POW_LIB@
 PTHREAD_CC = @PTHREAD_CC@
 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
 PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_ABI_FLAGS = @PYTHON_ABI_FLAGS@
+PYTHON_CFLAGS = @PYTHON_CFLAGS@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXTENSION_SUFFIX = @PYTHON_EXTENSION_SUFFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PREFIX = @PYTHON_PREFIX@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -323,6 +332,8 @@ UDUNITS_LDFLAGS = @UDUNITS_LDFLAGS@
 UDUNITS_LIBS = @UDUNITS_LIBS@
 VERSINFO = @VERSINFO@
 VERSION = @VERSION@
+VIRTUALENV = @VIRTUALENV@
+VIRTUALENV_FLAGS = @VIRTUALENV_FLAGS@
 XERCESCPPFLAGS = @XERCESCPPFLAGS@
 XERCESLDFLAGS = @XERCESLDFLAGS@
 XERCES_CFLAGS = @XERCES_CFLAGS@
@@ -377,10 +388,12 @@ pdfdir = @pdfdir@
 pkg_cflags = @pkg_cflags@
 pkg_libs = @pkg_libs@
 pkg_requires = @pkg_requires@
+pkgpythondir = @pkgpythondir@
 plugin_sfx = @plugin_sfx@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+pythondir = @pythondir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 sovers = @sovers@
diff --git a/configure b/configure
index 894bf67..b74d667 100755
--- a/configure
+++ b/configure
@@ -697,7 +697,20 @@ BOOST_CPPFLAGS
 DISTCHECK_CONFIGURE_FLAGS
 BOOST_ROOT
 HAVE_CXX11
+PYTHON_ABI_FLAGS
+PYTHON_EXTENSION_SUFFIX
+PYTHON_LDFLAGS
+PYTHON_CFLAGS
+PYTHON_LIBS
+PYTHON_INCLUDES
 VERSINFO
+VIRTUALENV_FLAGS
+VIRTUALENV
+pkgpythondir
+pythondir
+PYTHON_PREFIX
+PYTHON_CONFIG
+PYTHON
 CXXCPP
 CPP
 OTOOL64
@@ -833,6 +846,7 @@ enable_dependency_tracking
 with_gnu_ld
 with_sysroot
 enable_libtool_lock
+with_virtualenv
 enable_release
 enable_c__11
 with_mpi
@@ -870,6 +884,9 @@ CXXFLAGS
 CCC
 CPP
 CXXCPP
+PYTHON
+PYTHON_CONFIG
+VIRTUALENV_FLAGS
 BOOST_ROOT
 PKG_CONFIG
 PKG_CONFIG_PATH
@@ -1532,6 +1549,7 @@ Optional Packages:
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-sysroot=DIR Search for dependent libraries within DIR
                         (or the compiler's sysroot if not specified).
+  --with-virtualenv       install to a Python virtualenv
   --with-mpi              compile with MPI (parallelization) support. If none
                           is found, MPI is not used. Default: auto
 
@@ -1581,6 +1599,11 @@ Some influential environment variables:
   CXXFLAGS    C++ compiler flags
   CPP         C preprocessor
   CXXCPP      C++ preprocessor
+  PYTHON      the Python interpreter
+  PYTHON_CONFIG
+              the Python-config program
+  VIRTUALENV_FLAGS
+              flags to pass to the virtualenv command
   BOOST_ROOT  Location of Boost installation
   PKG_CONFIG  path to pkg-config utility
   PKG_CONFIG_PATH
@@ -2063,6 +2086,185 @@ fi
 
 } # ac_fn_cxx_try_link
 
+# ac_fn_py_try_run LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_py_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_py_try_run
+
+# ac_fn_py_try_link LINENO
+# ------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_py_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_py_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_py_try_link
+
+# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES
+# ---------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_cxx_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if eval \${$3+:} false; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ----------------------------------- ##
+## Report this to gyoto at sympa.obspm.fr ##
+## ----------------------------------- ##"
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_cxx_check_header_mongrel
+
 # ac_fn_cxx_check_type LINENO TYPE VAR INCLUDES
 # ---------------------------------------------
 # Tests whether TYPE exists after having included INCLUDES, setting cache
@@ -15457,6 +15659,419 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 ac_config_headers="$ac_config_headers config.h include/GyotoConfig.h"
 
 
+
+# PYTHON STUFF
+
+
+
+
+for ac_prog in python \
+     python3 \
+     python2 \
+                         python3.4                    python3.3                    python3.2                    python3.1                    python3.0                                                            python2.7
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PYTHON+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PYTHON in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PYTHON=$ac_cv_path_PYTHON
+if test -n "$PYTHON"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
+$as_echo "$PYTHON" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$PYTHON" && break
+done
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if Python >= '2.7'" >&5
+$as_echo_n "checking if Python >= '2.7'... " >&6; }
+if ${pc_cv_python_req_version_2_7+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=py
+ac_compile='chmod +x conftest.$ac_ext >&5'
+ac_link='chmod +x conftest.$ac_ext && cp conftest.$ac_ext conftest >&5'
+     if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  cat > conftest.$ac_ext <<_ACEOF
+#!$PYTHON
+import sys
+
+if __name__ == '__main__':
+    # split strings by '.' and convert to numeric.  Append some zeros
+    # because we need at least 4 digits for the hex conversion.
+    # map returns an iterator in Python 3.0 and a list in 2.x
+    reqver = list(map(int, '2.7'.split('.'))) + [0, 0, 0]
+    reqverhex = 0
+    # xrange is not present in Python 3.0 and range returns an iterator
+    for i in list(range(4)):
+        reqverhex = (reqverhex << 8) + reqver[i]
+    # the final 8 bits are "0xf0" for final versions, which are all
+    # we'll test against, since it's doubtful that a released software
+    # will depend on an alpha- or beta-state Python.
+    reqverhex += 0xf0
+    if sys.hexversion >= reqverhex:
+        sys.exit()
+    else:
+        sys.exit(1)
+
+_ACEOF
+if ac_fn_py_try_run "$LINENO"; then :
+  pc_cv_python_req_version_2_7=yes
+else
+  pc_cv_python_req_version_2_7=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+     ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_cv_python_req_version_2_7" >&5
+$as_echo "$pc_cv_python_req_version_2_7" >&6; }
+if test "$pc_cv_python_req_version_2_7" = "no"; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "No compatible Python interpreter found. If you're sure that you have one, try setting the PYTHON environment variable to the location of the interpreter.
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if Python <= '3.4.99'" >&5
+$as_echo_n "checking if Python <= '3.4.99'... " >&6; }
+if ${pc_cv_python_req_version_3_4_99+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=py
+ac_compile='chmod +x conftest.$ac_ext >&5'
+ac_link='chmod +x conftest.$ac_ext && cp conftest.$ac_ext conftest >&5'
+     if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  cat > conftest.$ac_ext <<_ACEOF
+#!$PYTHON
+import sys
+
+if __name__ == '__main__':
+    # split strings by '.' and convert to numeric.  Append some zeros
+    # because we need at least 4 digits for the hex conversion.
+    # map returns an iterator in Python 3.0 and a list in 2.x
+    reqver = list(map(int, '3.4.99'.split('.'))) + [0, 0, 0]
+    reqverhex = 0
+    # xrange is not present in Python 3.0 and range returns an iterator
+    for i in list(range(4)):
+        reqverhex = (reqverhex << 8) + reqver[i]
+    # the final 8 bits are "0xf0" for final versions, which are all
+    # we'll test against, since it's doubtful that a released software
+    # will depend on an alpha- or beta-state Python.
+    reqverhex += 0xf0
+    if sys.hexversion <= reqverhex:
+        sys.exit()
+    else:
+        sys.exit(1)
+
+_ACEOF
+if ac_fn_py_try_run "$LINENO"; then :
+  pc_cv_python_req_version_3_4_99=yes
+else
+  pc_cv_python_req_version_3_4_99=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+     ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_cv_python_req_version_3_4_99" >&5
+$as_echo "$pc_cv_python_req_version_3_4_99" >&6; }
+if test "$pc_cv_python_req_version_3_4_99" = "no"; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "No compatible Python interpreter found. If you're sure that you have one, try setting the PYTHON environment variable to the location of the interpreter.
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+
+
+
+# Extract the first word of "`basename $PYTHON`-config", so it can be a program name with args.
+set dummy `basename $PYTHON`-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PYTHON_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PYTHON_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PYTHON_CONFIG="$PYTHON_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PYTHON_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PYTHON_CONFIG=$ac_cv_path_PYTHON_CONFIG
+if test -n "$PYTHON_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_CONFIG" >&5
+$as_echo "$PYTHON_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python prefix" >&5
+$as_echo_n "checking for Python prefix... " >&6; }
+if ${pc_cv_python_prefix+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_prefix=`$PYTHON_CONFIG --prefix 2>&5`
+else
+    ac_ext=py
+ac_compile='chmod +x conftest.$ac_ext >&5'
+ac_link='chmod +x conftest.$ac_ext && cp conftest.$ac_ext conftest >&5'
+    cat > conftest.$ac_ext <<_ACEOF
+#!$PYTHON
+import sys
+
+if __name__ == '__main__':
+    sys.stdout.write(sys.prefix)
+
+_ACEOF
+if ac_fn_py_try_link "$LINENO"; then :
+  pc_cv_python_prefix=`./conftest`;
+      if test $? != 0; then
+         { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "could not determine Python prefix
+See \`config.log' for more details" "$LINENO" 5; }
+      fi
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to run Python program
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_cv_python_prefix" >&5
+$as_echo "$pc_cv_python_prefix" >&6; }
+PYTHON_PREFIX=$pc_cv_python_prefix
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python site-packages directory" >&5
+$as_echo_n "checking for Python site-packages directory... " >&6; }
+if ${pc_cv_python_site_dir+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=py
+ac_compile='chmod +x conftest.$ac_ext >&5'
+ac_link='chmod +x conftest.$ac_ext && cp conftest.$ac_ext conftest >&5'
+    if test "x$prefix" = xNONE
+     then
+       pc_py_prefix=$ac_default_prefix
+     else
+       pc_py_prefix=$prefix
+     fi
+     cat > conftest.$ac_ext <<_ACEOF
+#!$PYTHON
+import sys
+from platform import python_implementation
+# sysconfig in CPython 2.7 doesn't work in virtualenv
+# <https://github.com/pypa/virtualenv/issues/118>
+try:
+    import sysconfig
+except:
+    can_use_sysconfig = False
+else:
+    can_use_sysconfig = True
+if can_use_sysconfig:
+    if python_implementation() == "CPython" and sys.version[:3] == '2.7':
+        can_use_sysconfig = False
+if not can_use_sysconfig:
+    from distutils import sysconfig
+    sitedir = sysconfig.get_python_lib(False, False, prefix='$pc_py_prefix')
+else:
+    sitedir = sysconfig.get_path('purelib', vars={'base':'$pc_py_prefix'})
+
+if __name__ == '__main__':
+    sys.stdout.write(sitedir)
+
+_ACEOF
+if ac_fn_py_try_link "$LINENO"; then :
+  pc_cv_python_site_dir=`./conftest`
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to run Python program
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+     case $pc_cv_python_site_dir in
+     $pc_py_prefix*)
+       pc__strip_prefix=`echo "$pc_py_prefix" | sed 's|.|.|g'`
+       pc_cv_python_site_dir=`echo "$pc_cv_python_site_dir" | sed "s,^$pc__strip_prefix/,,"`
+       ;;
+     *)
+       case $pc_py_prefix in
+         /usr|/System*) ;;
+         *)
+	  pc_cv_python_site_dir=lib/python$PYTHON_VERSION/site-packages
+	  ;;
+       esac
+       ;;
+     esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_cv_python_site_dir" >&5
+$as_echo "$pc_cv_python_site_dir" >&6; }
+pythondir=\${prefix}/$pc_cv_python_site_dir
+
+pkgpythondir=\${pythondir}/$PACKAGE_NAME
+
+
+# Check whether --with-virtualenv was given.
+if test "${with_virtualenv+set}" = set; then :
+  withval=$with_virtualenv;
+else
+  with_virtualenv=no
+fi
+
+if test "x$with_virtualenv" != xno; then :
+  for ac_prog in virtualenv virtualenv3 virtualenv2
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_VIRTUALENV+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$VIRTUALENV"; then
+  ac_cv_prog_VIRTUALENV="$VIRTUALENV" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_VIRTUALENV="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+VIRTUALENV=$ac_cv_prog_VIRTUALENV
+if test -n "$VIRTUALENV"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $VIRTUALENV" >&5
+$as_echo "$VIRTUALENV" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$VIRTUALENV" && break
+done
+test -n "$VIRTUALENV" || VIRTUALENV="no"
+
+	    if test "x$VIRTUALENV" = xno; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "--with-virtualenv given but virtualenv could not be found
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+else
+  VIRTUALENV=no
+
+fi
+
+
 VERSINFO=3:0:1
 
 
@@ -15470,6 +16085,120 @@ if test "x$enable_release" != "xyes"; then :
   FEATURES+="-unreleased"
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python includes" >&5
+$as_echo_n "checking for Python includes... " >&6; }
+if ${pc_cv_python_includes+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_includes=`$PYTHON_CONFIG --includes 2>&5`
+else
+    pc_cv_python_includes="-I$includedir/$_PYTHON_BASENAME"
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_cv_python_includes" >&5
+$as_echo "$pc_cv_python_includes" >&6; }
+PYTHON_INCLUDES=$pc_cv_python_includes
+
+
+pc_cflags_store=$CPPFLAGS
+CPPFLAGS="$CFLAGS $PYTHON_INCLUDES"
+ac_fn_cxx_check_header_mongrel "$LINENO" "Python.h" "ac_cv_header_Python_h" "$ac_includes_default"
+if test "x$ac_cv_header_Python_h" = xyes; then :
+
+else
+  PYTHON=""
+fi
+
+
+CPPFLAGS=$pc_cflags_store
+
+if test "x$PYTHON" != "x"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python libs" >&5
+$as_echo_n "checking for Python libs... " >&6; }
+if ${pc_cv_python_libs+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_libs=`$PYTHON_CONFIG --libs 2>&5`
+else
+    pc_cv_python_libs="-l$_PYTHON_BASENAME"
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_cv_python_libs" >&5
+$as_echo "$pc_cv_python_libs" >&6; }
+PYTHON_LIBS=$pc_cv_python_libs
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python CFLAGS" >&5
+$as_echo_n "checking for Python CFLAGS... " >&6; }
+if ${pc_cv_python_cflags+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_cflags=`$PYTHON_CONFIG --cflags 2>&5`
+else
+    pc_cv_python_cflags=
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_cv_python_cflags" >&5
+$as_echo "$pc_cv_python_cflags" >&6; }
+PYTHON_CFLAGS=$pc_cv_python_cflags
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python LDFLAGS" >&5
+$as_echo_n "checking for Python LDFLAGS... " >&6; }
+if ${pc_cv_python_ldflags+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_ldflags=`$PYTHON_CONFIG --ldflags 2>&5`
+else
+    pc_cv_python_ldflags=
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_cv_python_ldflags" >&5
+$as_echo "$pc_cv_python_ldflags" >&6; }
+PYTHON_LDFLAGS=$pc_cv_python_ldflags
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python extension suffix" >&5
+$as_echo_n "checking for Python extension suffix... " >&6; }
+if ${pc_cv_python_extension_suffix+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -x "$PYTHON_CONFIG"; then
+     pc_cv_python_extension_suffix=`$PYTHON_CONFIG --extension-suffix 2>&5`
+else
+    pc_cv_python_extension_suffix=
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_cv_python_extension_suffix" >&5
+$as_echo "$pc_cv_python_extension_suffix" >&6; }
+PYTHON_EXTENSION_SUFFIX=$pc_cv_python_extension_suffix
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python ABI flags" >&5
+$as_echo_n "checking for Python ABI flags... " >&6; }
+if ${pc_cv_python_abi_flags+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -x "$PYTHON_CONFIG"; then
+     pc_cv_python_abi_flags=`$PYTHON_CONFIG --abiflags 2>&5`
+else
+    pc_cv_python_abi_flags=
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_cv_python_abi_flags" >&5
+$as_echo "$pc_cv_python_abi_flags" >&6; }
+PYTHON_ABI_FLAGS=$pc_cv_python_abi_flags
+
+
+
+fi
+# DONE WITH PYTHON STUFF
 
 # Checks for programs.
 
@@ -15692,7 +16421,6 @@ fi
 
 
 # Check for boost
-
 if test "x$HAVE_CXX11" = "x1"; then :
   have_boost=yes
    echo "$as_me: this is boost.m4 serial 22" >&5
@@ -16007,6 +16735,7 @@ fi
 
 
 
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
 $as_echo_n "checking whether ln -s works... " >&6; }
 LN_S=$as_ln_s
@@ -18562,6 +19291,13 @@ if test "x$YORICK" != "x"; then :
 
 
 fi
+if test "x$PYTHON" != "x"; then :
+
+   ac_config_files="$ac_config_files python/Makefile python/setup.py"
+
+
+
+fi
 if test "x$DOXYGEN" != "x" && test "x$mkdoc" == "xyes"; then :
   mySUBDIRS="$mySUBDIRS doc"
    ac_config_files="$ac_config_files doc/doxyfile"
@@ -19725,6 +20461,8 @@ do
     "yorick/yorick1") CONFIG_FILES="$CONFIG_FILES yorick/yorick1" ;;
     "yorick/setpaths.i") CONFIG_FILES="$CONFIG_FILES yorick/setpaths.i" ;;
     "gyoto") CONFIG_FILES="$CONFIG_FILES gyoto" ;;
+    "python/Makefile") CONFIG_FILES="$CONFIG_FILES python/Makefile" ;;
+    "python/setup.py") CONFIG_FILES="$CONFIG_FILES python/setup.py" ;;
     "doc/doxyfile") CONFIG_FILES="$CONFIG_FILES doc/doxyfile" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
diff --git a/configure.ac b/configure.ac
index 38e0a64..b2f849f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,13 @@
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
+# Few bits where taken from pyconf, bearing this notice:
+dnl Copyright 2012, 2013 Brandon Invergo <brandon at invergo.net>
+dnl
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.  This file is offered as-is,
+dnl without any warranty.
+
 
 AC_PREREQ([2.69])
 AC_INIT([Gyoto], [0.2.0], [gyoto at sympa.obspm.fr])
@@ -13,6 +21,23 @@ AC_LANG(C++)
 LT_INIT([dlopen disable-static])
 AC_CONFIG_HEADERS([config.h include/GyotoConfig.h]) 
 
+
+# PYTHON STUFF
+PC_INIT([2.7], [3.4.99])
+PC_PYTHON_CHECK_SITE_DIR
+PC_PYTHON_SITE_PACKAGE_DIR
+AC_ARG_WITH([virtualenv],
+	[AS_HELP_STRING([--with-virtualenv], [install to a Python virtualenv])],
+	[],
+	[with_virtualenv=no])
+AS_IF([test "x$with_virtualenv" != xno],
+	    AC_CHECK_PROGS([VIRTUALENV], [virtualenv virtualenv3 virtualenv2], [no])
+	    AS_IF([test "x$VIRTUALENV" = xno],
+	    [AC_MSG_FAILURE(
+		[--with-virtualenv given but virtualenv could not be found])]),
+	AC_SUBST([VIRTUALENV], [no]))
+AC_ARG_VAR([VIRTUALENV_FLAGS], [flags to pass to the virtualenv command])
+
 VERSINFO=3:0:1
 AC_SUBST([VERSINFO])
 
@@ -23,6 +48,16 @@ AC_ARG_ENABLE([release],
 AS_IF([test "x$enable_release" != "xyes"],
   [FEATURES+="-unreleased"])
 
+PC_PYTHON_CHECK_HEADERS(,[PYTHON=""])
+AS_IF([test "x$PYTHON" != "x"],
+  [PC_PYTHON_CHECK_LIBS
+   PC_PYTHON_CHECK_CFLAGS
+   PC_PYTHON_CHECK_LDFLAGS
+   PC_PYTHON_CHECK_EXTENSION_SUFFIX
+   PC_PYTHON_CHECK_ABI_FLAGS
+  ]
+)
+# DONE WITH PYTHON STUFF
 
 # Checks for programs.
 
@@ -94,6 +129,7 @@ AS_IF([test "x$have_mpi" == xyes],
 
 AM_CONDITIONAL(HAVE_MPI, [test "x$have_mpi" == xyes])
 
+AC_PROG_MKDIR_P
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
@@ -726,6 +762,11 @@ AS_IF([test "x$YORICK" != "x"],
 		   [chmod a+x gyoto])
   ]
 )
+AS_IF([test "x$PYTHON" != "x"],
+  [
+   AC_CONFIG_FILES([python/Makefile python/setup.py])
+  ]
+)
 AS_IF([test "x$DOXYGEN" != "x" && test "x$mkdoc" == "xyes"],
   [mySUBDIRS="$mySUBDIRS doc"
    AC_CONFIG_FILES([doc/doxyfile])
diff --git a/lib/Makefile.in b/lib/Makefile.in
index f5bb0bb..8987e1d 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -98,7 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
 	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pkg.m4 \
-	$(top_srcdir)/configure.ac
+	$(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -330,6 +330,15 @@ POW_LIB = @POW_LIB@
 PTHREAD_CC = @PTHREAD_CC@
 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
 PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_ABI_FLAGS = @PYTHON_ABI_FLAGS@
+PYTHON_CFLAGS = @PYTHON_CFLAGS@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXTENSION_SUFFIX = @PYTHON_EXTENSION_SUFFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PREFIX = @PYTHON_PREFIX@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
@@ -342,6 +351,8 @@ UDUNITS_LDFLAGS = @UDUNITS_LDFLAGS@
 UDUNITS_LIBS = @UDUNITS_LIBS@
 VERSINFO = @VERSINFO@
 VERSION = @VERSION@
+VIRTUALENV = @VIRTUALENV@
+VIRTUALENV_FLAGS = @VIRTUALENV_FLAGS@
 XERCESCPPFLAGS = @XERCESCPPFLAGS@
 XERCESLDFLAGS = @XERCESLDFLAGS@
 XERCES_CFLAGS = @XERCES_CFLAGS@
@@ -396,10 +407,12 @@ pdfdir = @pdfdir@
 pkg_cflags = @pkg_cflags@
 pkg_libs = @pkg_libs@
 pkg_requires = @pkg_requires@
+pkgpythondir = @pkgpythondir@
 plugin_sfx = @plugin_sfx@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+pythondir = @pythondir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 sovers = @sovers@
diff --git a/m4/python.m4 b/m4/python.m4
new file mode 100644
index 0000000..58aef43
--- /dev/null
+++ b/m4/python.m4
@@ -0,0 +1,646 @@
+# Copyright 2012, 2013, 2014 Brandon Invergo <brandon at invergo.net>
+#
+# This file is part of pyconfigure.  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 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the Autoconf Configure Script Exception,
+# version 3.0, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License
+# and a copy of the Autoconf Configure Script Exception along with
+# this program; see the files COPYINGv3 and COPYING.EXCEPTION
+# respectively.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Many of these macros were adapted from ones written by Andrew Dalke
+# and James Henstridge and are included with the Automake utility
+# under the following copyright terms:
+#
+# Copyright (C) 1999-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# Table of Contents:
+#
+# 1. Language selection
+#    and routines to produce programs in a given language.
+#
+# 2. Producing programs in a given language.
+#
+# 3. Looking for a compiler
+#    And possibly the associated preprocessor.
+#
+# 4. Looking for specific libs & functionality
+
+
+## ----------------------- ##
+## 1. Language selection.  ##
+## ----------------------- ##
+
+
+# AC_LANG(Python)
+# ---------------
+AC_LANG_DEFINE([Python], [py], [PY], [PYTHON], [],
+[ac_ext=py
+ac_compile='chmod +x conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+ac_link='chmod +x conftest.$ac_ext && cp conftest.$ac_ext conftest >&AS_MESSAGE_LOG_FD'
+])
+
+
+# AC_LANG_PYTHON
+# --------------
+AU_DEFUN([AC_LANG_PYTHON], [AC_LANG(Python)])
+
+
+## ----------------------- ##
+## 2. Producing programs.  ##
+## ----------------------- ##
+
+
+# AC_LANG_PROGRAM(Python)([PROLOGUE], [BODY])
+# -------------------------------------------
+m4_define([AC_LANG_PROGRAM(Python)], [dnl
+@%:@!$PYTHON
+$1
+m4_if([$2], [], [], [dnl
+if __name__ == '__main__':
+$2])])
+
+
+# _AC_LANG_IO_PROGRAM(Python)
+# ---------------------------
+# Produce source that performs I/O.
+m4_define([_AC_LANG_IO_PROGRAM(Python)],
+[AC_LANG_PROGRAM([dnl
+import sys
+try:
+    h = open('conftest.out')
+except:
+    sys.exit(1)
+else:
+    close(h)
+    sys.exit(0)
+], [])])
+
+
+# _AC_LANG_CALL(Python)([PROLOGUE], [FUNCTION])
+# ---------------------
+# Produce source that calls FUNCTION
+m4_define([_AC_LANG_CALL(Python)],
+[AC_LANG_PROGRAM([$1], [$2])])
+
+
+## -------------------------------------------- ##
+## 3. Looking for Compilers and Interpreters.   ##
+## -------------------------------------------- ##
+
+
+AC_DEFUN([AC_LANG_COMPILER(Python)],
+[AC_REQUIRE([PC_PROG_PYTHON])])
+
+
+# PC_INIT([MIN-VERSION], [MAX-VERSION]) 
+# -----------------------------
+# Initialize pyconfigure, finding a Python interpreter with a given
+# minimum and/or maximum version. 
+AC_DEFUN([PC_INIT],
+[PC_PROG_PYTHON([], [$1], [$2])
+dnl If we found something, do a sanity check that the interpreter really
+dnl has the version its name would suggest.
+m4_ifval([PYTHON],
+        [PC_PYTHON_VERIFY_VERSION([>=], [pc_min_ver], [],
+                  [AC_MSG_FAILURE([No compatible Python interpreter found. If you're sure that you have one, try setting the PYTHON environment variable to the location of the interpreter.])])])
+m4_ifval([PYTHON],
+        [PC_PYTHON_VERIFY_VERSION([<=], [pc_max_ver], [],
+                  [AC_MSG_FAILURE([No compatible Python interpreter found. If you're sure that you have one, try setting the PYTHON environment variable to the location of the interpreter.])])])
+])# PC_INIT
+
+# PC_PROG_PYTHON([PROG-TO-CHECK-FOR], [MIN-VERSION], [MAX-VERSION])
+# ---------------------------------
+# Find a Python interpreter.  Python versions prior to 2.0 are not
+# supported. (2.0 was released on October 16, 2000).
+AC_DEFUN_ONCE([PC_PROG_PYTHON],
+[AC_ARG_VAR([PYTHON], [the Python interpreter])
+dnl The default minimum version is 2.0
+m4_define_default([pc_min_ver], m4_ifval([$2], [$2], [2.0]))
+dnl The default maximum version is 3.3
+m4_define_default([pc_max_ver], m4_ifval([$3], [$3], [4.0]))
+dnl Build up a list of possible interpreter names. 
+m4_define_default([_PC_PYTHON_INTERPRETER_LIST],
+    [[python] \
+dnl If we want some Python 3 versions (max version >= 3.0), 
+dnl also search for "python3"
+     m4_if(m4_version_compare(pc_max_ver, [2.9]), [1], [python3], []) \
+dnl If we want some Python 2 versions (min version <= 2.7),
+dnl also search for "python2".
+     m4_if(m4_version_compare(pc_min_ver, [2.8]), [-1], [python2], []) \
+dnl Construct a comma-separated list of interpreter names (python2.6, 
+dnl python2.7, etc). We only care about the first 3 characters of the
+dnl version strings (major-dot-minor; not 
+dnl major-dot-minor-dot-bugfix[-dot-whatever])
+     m4_foreach([pc_ver], 
+                    m4_esyscmd_s(seq -s[[", "]] -f["[[%.1f]]"] m4_substr(pc_max_ver, [0], [3]) -0.1 m4_substr(pc_min_ver, [0], [3])),
+dnl Remove python2.8 and python2.9 since they will never exist
+                    [m4_bmatch(pc_ver, [2.[89]], [], [python]pc_ver)])])
+dnl Do the actual search at last.
+m4_ifval([$1],
+	[AC_PATH_PROGS(PYTHON, [$1 _PC_PYTHON_INTERPRETER_LIST])],
+	[AC_PATH_PROGS(PYTHON, [_PC_PYTHON_INTERPRETER_LIST])])
+])# PC_PROG_PYTHON
+  
+
+# PC_PYTHON_PROG_PYTHON_CONFIG(PROG-TO-CHECK-FOR)
+# ----------------------------------------------
+# Find the python-config program
+AC_DEFUN([PC_PYTHON_PROG_PYTHON_CONFIG],
+[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
+AC_ARG_VAR([PYTHON_CONFIG], [the Python-config program])
+dnl python-config's binary name is normally based on the Python interpreter's
+dnl binary name (i.e. python2.7 -> python2.7-config)
+m4_define([_PYTHON_BASENAME], [`basename $PYTHON`])
+m4_ifval([$1],
+	[AC_PATH_PROGS(PYTHON_CONFIG, [$1 _PYTHON_BASENAME-config])],
+	[AC_PATH_PROG(PYTHON_CONFIG, _PYTHON_BASENAME-config)])
+]) # PC_PYTHON_PROG_PYTHON_CONFIG
+
+
+# PC_PYTHON_VERIFY_VERSION([RELATION], [VERSION], [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+# ---------------------------------------------------------------------------
+# Run ACTION-IF-TRUE if the Python interpreter PROG has version [RELATION] VERSION.
+# i.e if RELATION is "<", check if PROG has a version number less than VERSION.
+# Run ACTION-IF-FALSE otherwise.
+# Specify RELATION as any mathematical comparison "<", ">", "<=", ">=", "==" or "!="
+# This test uses sys.hexversion instead of the string equivalent (first
+# word of sys.version), in order to cope with versions such as 2.2c1.
+# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
+AC_DEFUN([PC_PYTHON_VERIFY_VERSION],
+[m4_define([pc_python_safe_ver], m4_bpatsubsts($2, [\.], [_]))
+AC_CACHE_CHECK([if Python $1 '$2'],
+    [[pc_cv_python_req_version_]pc_python_safe_ver],
+    [AC_LANG_PUSH(Python)[]dnl
+     AC_RUN_IFELSE(
+        [AC_LANG_PROGRAM([dnl
+import sys
+], [dnl
+    # split strings by '.' and convert to numeric.  Append some zeros
+    # because we need at least 4 digits for the hex conversion.
+    # map returns an iterator in Python 3.0 and a list in 2.x
+    reqver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
+    reqverhex = 0
+    # xrange is not present in Python 3.0 and range returns an iterator
+    for i in list(range(4)):
+        reqverhex = (reqverhex << 8) + reqver[[i]]
+    # the final 8 bits are "0xf0" for final versions, which are all
+    # we'll test against, since it's doubtful that a released software
+    # will depend on an alpha- or beta-state Python.
+    reqverhex += 0xf0
+    if sys.hexversion $1 reqverhex:
+        sys.exit()
+    else:
+        sys.exit(1)
+])], 
+         [[pc_cv_python_req_version_]pc_python_safe_ver=yes], 
+         [[pc_cv_python_req_version_]pc_python_safe_ver=no])
+     AC_LANG_POP(Python)[]dnl
+    ])
+AS_IF([test "$[pc_cv_python_req_version_]pc_python_safe_ver" = "no"], [$4], [$3])
+])# PC_PYTHON_VERIFY_VERSION
+
+
+# PC_PYTHON_CHECK_VERSION
+# -----------------------
+# Query Python for its version number.  Getting [:3] seems to be
+# the best way to do this; it's what "site.py" does in the standard
+# library.
+AC_DEFUN([PC_PYTHON_CHECK_VERSION],
+[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
+AC_CACHE_CHECK([for $1 version], 
+    [pc_cv_python_version],
+    [AC_LANG_PUSH(Python)[]dnl
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
+import sys
+], [dnl
+    sys.stdout.write(sys.version[[:3]])
+])],
+                   [pc_cv_python_version=`./conftest`],
+                   [AC_MSG_FAILURE([failed to run Python program])])
+     AC_LANG_POP(Python)[]dnl
+    ])
+AC_SUBST([PYTHON_VERSION], [$pc_cv_python_version])
+])# PC_PYTHON_CHECK_VERSION
+
+
+# PC_PYTHON_CHECK_PREFIX
+# ----------------------
+# Use the value of $prefix for the corresponding value of
+# PYTHON_PREFIX. This is made a distinct variable so it can be
+# overridden if need be.  However, general consensus is that you
+# shouldn't need this ability. 
+AC_DEFUN([PC_PYTHON_CHECK_PREFIX],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to get it with python-config otherwise do it from within Python
+AC_CACHE_CHECK([for Python prefix], [pc_cv_python_prefix],
+[if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_prefix=`$PYTHON_CONFIG --prefix 2>&AS_MESSAGE_LOG_FD`
+else
+    AC_LANG_PUSH(Python)[]dnl
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
+import sys
+], [dnl
+    sys.stdout.write(sys.prefix)
+])], [pc_cv_python_prefix=`./conftest`;
+      if test $? != 0; then
+         AC_MSG_FAILURE([could not determine Python prefix])
+      fi],
+      [AC_MSG_FAILURE([failed to run Python program])])
+    AC_LANG_POP(Python)[]dnl
+fi])
+AC_SUBST([PYTHON_PREFIX], [$pc_cv_python_prefix])])
+
+
+# PC_PYTHON_CHECK_EXEC_PREFIX
+# --------------------------
+# Like above, but for $exec_prefix
+AC_DEFUN([PC_PYTHON_CHECK_EXEC_PREFIX],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to get it with python-config otherwise do it from within Python
+AC_CACHE_CHECK([for Python exec-prefix], [pc_cv_python_exec_prefix],
+[if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_exec_prefix=`$PYTHON_CONFIG --exec-prefix 2>&AS_MESSAGE_LOG_FD`
+else
+    AC_LANG_PUSH(Python)[]dnl
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
+import sys
+], [dnl
+    sys.stdout.write(sys.exec_prefix)
+])],
+        [pc_cv_python_exec_prefix=`./conftest`;
+         if test $? != 0; then
+            AC_MSG_FAILURE([could not determine Python exec_prefix])
+         fi],
+         [AC_MSG_FAILURE([failed to run Python program])])
+    AC_LANG_POP(Python)[]dnl
+fi
+])
+AC_SUBST([PYTHON_EXEC_PREFIX], [$pc_cv_python_exec_prefix])])
+
+
+# PC_PYTHON_CHECK_INCLUDES
+# ------------------------
+# Find the Python header file include flags (ie
+# '-I/usr/include/python')
+AC_DEFUN([PC_PYTHON_CHECK_INCLUDES],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the headers location with python-config otherwise guess
+AC_CACHE_CHECK([for Python includes], [pc_cv_python_includes],
+[if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_includes=`$PYTHON_CONFIG --includes 2>&AS_MESSAGE_LOG_FD`
+else
+    pc_cv_python_includes="[-I$includedir/$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS,
+    PYTHON_ABI_FLAGS,)"
+fi
+])
+AC_SUBST([PYTHON_INCLUDES], [$pc_cv_python_includes])])
+
+
+# PC_PYTHON_CHECK_HEADERS([ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
+# -----------------------
+# Check for the presence and usability of Python.h
+AC_DEFUN([PC_PYTHON_CHECK_HEADERS],
+[AC_REQUIRE([PC_PYTHON_CHECK_INCLUDES])[]dnl
+pc_cflags_store=$CPPFLAGS
+CPPFLAGS="$CFLAGS $PYTHON_INCLUDES"
+AC_CHECK_HEADER([Python.h], [$1], [$2])
+CPPFLAGS=$pc_cflags_store
+])
+
+
+# PC_PYTHON_CHECK_LIBS
+# --------------------
+# Find the Python lib flags (ie '-lpython')
+AC_DEFUN([PC_PYTHON_CHECK_LIBS],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the lib flags with python-config otherwise guess
+AC_CACHE_CHECK([for Python libs], [pc_cv_python_libs],
+[if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_libs=`$PYTHON_CONFIG --libs 2>&AS_MESSAGE_LOG_FD`
+else
+    pc_cv_python_libs="[-l$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS, PYTHON_ABI_FLAGS,)"
+fi
+])
+AC_SUBST([PYTHON_LIBS], [$pc_cv_python_libs])])
+
+
+# PC_PYTHON_TEST_LIBS(LIBRARY-FUNCTION, [ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
+# -------------------
+# Verify that the Python libs can be loaded
+AC_DEFUN([PC_PYTHON_TEST_LIBS],
+[AC_REQUIRE([PC_PYTHON_CHECK_LIBS])[]dnl
+pc_libflags_store=$LIBS
+for lflag in $PYTHON_LIBS; do
+    case $lflag in
+    	 -lpython*@:}@
+		LIBS="$LIBS $lflag"
+		pc_libpython=`echo $lflag | sed -e 's/^-l//'`
+		;;
+         *@:}@;;
+    esac
+done
+AC_CHECK_LIB([$pc_libpython], [$1], [$2], [$3])])
+
+
+# PC_PYTHON_CHECK_CFLAGS
+# ----------------------
+# Find the Python CFLAGS
+AC_DEFUN([PC_PYTHON_CHECK_CFLAGS],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the CFLAGS with python-config otherwise give up
+AC_CACHE_CHECK([for Python CFLAGS], [pc_cv_python_cflags],
+[if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_cflags=`$PYTHON_CONFIG --cflags 2>&AS_MESSAGE_LOG_FD`
+else
+    pc_cv_python_cflags=
+fi
+])
+AC_SUBST([PYTHON_CFLAGS], [$pc_cv_python_cflags])])
+
+
+# PC_PYTHON_CHECK_LDFLAGS
+# -----------------------
+# Find the Python LDFLAGS
+AC_DEFUN([PC_PYTHON_CHECK_LDFLAGS],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the LDFLAGS with python-config otherwise give up
+AC_CACHE_CHECK([for Python LDFLAGS], [pc_cv_python_ldflags],
+[if test -x "$PYTHON_CONFIG"; then
+    pc_cv_python_ldflags=`$PYTHON_CONFIG --ldflags 2>&AS_MESSAGE_LOG_FD`
+else
+    pc_cv_python_ldflags=
+fi
+])
+AC_SUBST([PYTHON_LDFLAGS], [$pc_cv_python_ldflags])])
+
+
+# PC_PYTHON_CHECK_EXTENSION_SUFFIX
+# --------------------------------
+# Find the Python extension suffix (i.e. '.cpython-32.so')
+AC_DEFUN([PC_PYTHON_CHECK_EXTENSION_SUFFIX],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the suffix with python-config otherwise give up
+AC_CACHE_CHECK([for Python extension suffix], [pc_cv_python_extension_suffix],
+[if test -x "$PYTHON_CONFIG"; then
+     pc_cv_python_extension_suffix=`$PYTHON_CONFIG --extension-suffix 2>&AS_MESSAGE_LOG_FD`
+else
+    pc_cv_python_extension_suffix=
+fi
+])
+AC_SUBST([PYTHON_EXTENSION_SUFFIX], [$pc_cv_python_extension_suffix])])
+
+
+# PC_PYTHON_CHECK_ABI_FLAGS
+# -------------------------
+# Find the Python ABI flags
+AC_DEFUN([PC_PYTHON_CHECK_ABI_FLAGS],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the ABI flags with python-config otherwise give up
+AC_CACHE_CHECK([for Python ABI flags], [pc_cv_python_abi_flags],
+[if test -x "$PYTHON_CONFIG"; then
+     pc_cv_python_abi_flags=`$PYTHON_CONFIG --abiflags 2>&AS_MESSAGE_LOG_FD`
+else
+    pc_cv_python_abi_flags=
+fi
+])
+AC_SUBST([PYTHON_ABI_FLAGS], [$pc_cv_python_abi_flags])])
+
+
+# PC_PYTHON_CHECK_PLATFORM
+# ------------------------
+# At times (like when building shared libraries) you may want
+# to know which OS platform Python thinks this is.
+AC_DEFUN([PC_PYTHON_CHECK_PLATFORM],
+[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
+dnl Get the platform from within Python (sys.platform)
+AC_CACHE_CHECK([for Python platform], [pc_cv_python_platform],
+    [AC_LANG_PUSH(Python)[]dnl
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
+import sys
+], [dnl
+    sys.stdout.write(sys.platform)
+])], [pc_cv_python_platform=`./conftest`;
+     if test $? != 0; then
+        AC_MSG_FAILURE([could not determine Python platform])
+     fi],
+     [AC_MSG_FAILURE([failed to run Python program])])
+    AC_LANG_POP(Python)[]dnl
+   ])
+AC_SUBST([PYTHON_PLATFORM], [$pc_cv_python_platform])
+])
+
+
+# PC_PYTHON_CHECK_SITE_DIR
+# ---------------------
+# The directory to which new libraries are installed (i.e. the
+# "site-packages" directory.
+AC_DEFUN([PC_PYTHON_CHECK_SITE_DIR],
+[AC_REQUIRE([PC_PROG_PYTHON])AC_REQUIRE([PC_PYTHON_CHECK_PREFIX])[]dnl
+AC_CACHE_CHECK([for Python site-packages directory],
+    [pc_cv_python_site_dir],
+    [AC_LANG_PUSH(Python)[]dnl
+    if test "x$prefix" = xNONE
+     then
+       pc_py_prefix=$ac_default_prefix
+     else
+       pc_py_prefix=$prefix
+     fi
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
+import sys
+from platform import python_implementation
+# sysconfig in CPython 2.7 doesn't work in virtualenv
+# <https://github.com/pypa/virtualenv/issues/118>
+try:
+    import sysconfig
+except:
+    can_use_sysconfig = False
+else:
+    can_use_sysconfig = True
+if can_use_sysconfig:
+    if python_implementation() == "CPython" and sys.version[[:3]] == '2.7':
+        can_use_sysconfig = False
+if not can_use_sysconfig:        
+    from distutils import sysconfig
+    sitedir = sysconfig.get_python_lib(False, False, prefix='$pc_py_prefix')
+else:
+    sitedir = sysconfig.get_path('purelib', vars={'base':'$pc_py_prefix'})
+], [dnl
+    sys.stdout.write(sitedir)
+])], [pc_cv_python_site_dir=`./conftest`],
+     [AC_MSG_FAILURE([failed to run Python program])])
+     AC_LANG_POP(Python)[]dnl
+     case $pc_cv_python_site_dir in
+     $pc_py_prefix*)
+       pc__strip_prefix=`echo "$pc_py_prefix" | sed 's|.|.|g'`
+       pc_cv_python_site_dir=`echo "$pc_cv_python_site_dir" | sed "s,^$pc__strip_prefix/,,"`
+       ;;
+     *)
+       case $pc_py_prefix in
+         /usr|/System*) ;;
+         *)
+	  pc_cv_python_site_dir=lib/python$PYTHON_VERSION/site-packages
+	  ;;
+       esac
+       ;;
+     esac
+     ])
+AC_SUBST([pythondir], [\${prefix}/$pc_cv_python_site_dir])])# PC_PYTHON_CHECK_SITE_DIR
+
+# PC_PYTHON_SITE_PACKAGE_DIR
+# --------------------------
+# $PACKAGE directory under PYTHON_SITE_DIR
+AC_DEFUN([PC_PYTHON_SITE_PACKAGE_DIR],
+[AC_REQUIRE([PC_PYTHON_CHECK_SITE_DIR])[]dnl
+AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE_NAME])])
+
+
+# PC_PYTHON_CHECK_EXEC_DIR
+# ------------------------
+# directory for installing python extension modules (shared libraries)
+AC_DEFUN([PC_PYTHON_CHECK_EXEC_DIR],
+[AC_REQUIRE([PC_PROG_PYTHON])AC_REQUIRE([PC_PYTHON_CHECK_EXEC_PREFIX])[]dnl
+  AC_CACHE_CHECK([for Python extension module directory],
+    [pc_cv_python_exec_dir],
+    [AC_LANG_PUSH(Python)[]dnl
+    if test "x$pc_cv_python_exec_prefix" = xNONE
+     then
+       pc_py_exec_prefix=$pc_cv_python_prefix
+     else
+       pc_py_exec_prefix=$pc_cv_python_exec_prefix
+     fi
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
+import sys
+from platform import python_implementation
+# sysconfig in CPython 2.7 doesn't work in virtualenv
+# <https://github.com/pypa/virtualenv/issues/118>
+try:
+    import sysconfig
+except:
+    can_use_sysconfig = False
+else:
+    can_use_sysconfig = True
+if can_use_sysconfig:
+    if python_implementation() == "CPython" and sys.version[[:3]] == '2.7':
+        can_use_sysconfig = False
+if not can_use_sysconfig:        
+    from distutils import sysconfig
+    sitedir = sysconfig.get_python_lib(False, False, prefix='$pc_py__exec_prefix')
+else:
+    sitedir = sysconfig.get_path('purelib', vars={'platbase':'$pc_py_exec_prefix'})
+], [dnl
+    sys.stdout.write(sitedir)
+])], [pc_cv_python_exec_dir=`./conftest`],
+     [AC_MSG_FAILURE([failed to run Python program])])
+     AC_LANG_POP(Python)[]dnl
+     case $pc_cv_python_exec_dir in
+     $pc_py_exec_prefix*)
+       pc__strip_prefix=`echo "$pc_py_exec_prefix" | sed 's|.|.|g'`
+       pc_cv_python_exec_dir=`echo "$pc_cv_python_exec_dir" | sed "s,^$pc__strip_prefix/,,"`
+       ;;
+     *)
+       case $pc_py_exec_prefix in
+         /usr|/System*) ;;
+         *)
+	   pc_cv_python_exec_dir=lib/python$PYTHON_VERSION/site-packages
+	   ;;
+       esac
+       ;;
+     esac
+    ])
+AC_SUBST([pyexecdir], [\${exec_prefix}/$pc_cv_python_pyexecdir])]) #PY_PYTHON_CHECK_EXEC_LIB_DIR
+
+
+# PC_PYTHON_EXEC_PACKAGE_DIR
+# --------------------------
+# $PACKAGE directory under PYTHON_SITE_DIR
+AC_DEFUN([PC_PYTHON_EXEC_PACKAGE_DIR],
+[AC_REQUIRE([PC_PYTHON_CHECK_EXEC_DIR])[]dnl
+AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE_NAME])])
+
+
+## -------------------------------------------- ##
+## 4. Looking for specific libs & functionality ##
+## -------------------------------------------- ##
+
+
+# PC_PYTHON_CHECK_MODULE(LIBRARY, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# ----------------------------------------------------------------------
+# Macro for checking if a Python library is installed
+AC_DEFUN([PC_PYTHON_CHECK_MODULE],
+[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
+m4_define([pc_python_safe_mod], m4_bpatsubsts($1, [\.], [_]))
+AC_CACHE_CHECK([for Python '$1' library],
+    [[pc_cv_python_module_]pc_python_safe_mod],
+    [AC_LANG_PUSH(Python)[]dnl
+     AC_RUN_IFELSE(
+	[AC_LANG_PROGRAM([dnl
+import sys
+try:
+    import $1
+except:
+    sys.exit(1)
+else:
+    sys.exit(0)
+], [])],
+	[[pc_cv_python_module_]pc_python_safe_mod="yes"],
+	[[pc_cv_python_module_]pc_python_safe_mod="no"])
+     AC_LANG_POP(Python)[]dnl
+    ])
+AS_IF([test "$[pc_cv_python_module_]pc_python_safe_mod" = "no"], [$3], [$2])
+])# PC_PYTHON_CHECK_MODULE
+
+
+# PC_PYTHON_CHECK_FUNC([LIBRARY], FUNCTION, ARGS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# ---------------------------------------------------------------------------------------
+# Check to see if a given function call, optionally from a module, can
+# be successfully called
+AC_DEFUN([PC_PYTHON_CHECK_FUNC],
+[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
+m4_define([pc_python_safe_mod], m4_bpatsubsts($1, [\.], [_]))
+AC_CACHE_CHECK([for Python m4_ifnblank($1, '$1.$2()', '$2()') function],
+    [[pc_cv_python_func_]pc_python_safe_mod[_$2]],
+    [AC_LANG_PUSH(Python)[]dnl
+     AC_RUN_IFELSE(
+	[AC_LANG_PROGRAM([dnl
+import sys
+m4_ifnblank([$1], [dnl
+try:
+    import $1
+except:
+    sys.exit(1)
+], [])], 
+[
+m4_ifnblank([$1], [
+    try:
+        $1.$2($3)], [
+    try:
+        $2($3)])
+    except:
+        sys.exit(1)
+    else:
+        sys.exit(0)
+])],
+	[[pc_cv_python_func_]pc_python_safe_mod[_$2]="yes"],
+	[[pc_cv_python_func_]pc_python_safe_mod[_$2]="no"])
+     AC_LANG_POP(Python)[]dnl
+    ])
+AS_IF([test "$[pc_cv_python_func_]pc_python_safe_mod[_$2]" = "no"], [$5], [$4])
+])# PC_PYTHON_CHECK_FUNC
diff --git a/python/Makefile.in b/python/Makefile.in
new file mode 100644
index 0000000..378856e
--- /dev/null
+++ b/python/Makefile.in
@@ -0,0 +1,201 @@
+# Makefile.in
+#
+# Copyright © 2012, 2013 Brandon Invergo <brandon at invergo.net>
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.  This file is offered as-is,
+# without any warranty.
+
+# List whatever files you want to include in your source distribution here.
+# You can include whole directories but note that *everything* under that 
+# directory will be included
+DISTFILES = PKG-INFO Makefile.in configure setup.py install-sh
+
+DESTDIR = 
+VPATH = @srcdir@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_DISTNAME = ${PACKAGE_NAME}-${PACKAGE_VERSION}
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+VIRTUALENV = @VIRTUALENV@
+SPHINXBUILD = @SPHINXBUILD@
+SHELL = @SHELL@
+MKDIR_P = @MKDIR_P@
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+prefix = @prefix@
+srcdir = @srcdir@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+pythondir = @pythondir@
+pyexecdir = @pyexecdir@
+pkgdatadir = $(datadir)/@PACKAGE_NAME@
+pkgincludedir = $(includedir)/@PACKAGE_NAME@
+pkgpythondir = @pkgpythondir@
+pkgpyexecdir = @pkgpyexecdir@
+PYTHONPATH = $(pythondir)$(PATH_SEPARATOR)$(DESTDIR)$(pythondir)
+
+CFITSIO_CFLAGS = @CFITSIO_CFLAGS@
+CFITSIO_LIBS = @CFITSIO_LIBS@
+XERCES_CFLAGS = @XERCES_CFLAGS@
+XERCES_LIBS = @XERCES_LIBS@
+
+CXX=@CXX@
+CC=$(CXX)
+
+PYTHON = @PYTHON@
+PYTHON_ABI_FLAGS = @PYTHON_ABI_FLAGS@
+PYTHON_CFLAGS = @PYTHON_CFLAGS@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_EXTENSION_SUFFIX = @PYTHON_EXTENSION_SUFFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+
+FEATURES=@FEATURES@
+
+LDFLAGS=-L../lib/.libs -lgyoto$(FEATURES) $(CFITSIO_LIBS) $(XERCES_LIBS)
+CPPFLAGS=-I../include $(CFITSIO_CFLAGS) $(XERCES_CFLAGS)
+CXXFLAGS=@CXXFLAGS@ $(CFITSIO_CFLAGS) $(XERCES_CFLAGS)
+CFLAGS=$(CXXFLAGS)
+
+export LDFLAGS
+export CFLAGS
+export CPPFLAGS
+export CXXFLAGS
+export CC
+
+all: gyoto.py _gyoto$(PYTHON_EXTENSION_SUFFIX)
+
+_gyoto$(PYTHON_EXTENSION_SUFFIX): $(srcdir)/gyoto.cxx gyoto_wrap.cxx
+	$(PYTHON) $(srcdir)/setup.py build_ext
+
+gyoto.py gyoto_wrap.cxx:
+	swig2.0 -I$(srcdir)/../include -c++ -python  $(srcdir)/gyoto.i
+
+.PHONY: all install uninstall distclean info install-html html install-pdf pdf install-dvi dvi install-ps ps clean dist check installdirs
+
+
+# Since installing to a virtualenv is all the rage these days, support it here. If the VIRTUALENV
+# variable is set to anything other than "no", set up a new virtualenv and install there, otherwise
+# install as usual from setup.py
+install: installdirs
+	$(PYTHON) $(srcdir)/setup.py install
+ifneq ($(VIRTUALENV),no)
+	$(VIRTUALENV) $(VIRTUALENV_FLAGS) $(DESTDIR)$(prefix) || $(VIRTUALENV) $(DESTDIR)$(prefix)
+	$(DESTDIR)$(prefix)/bin/python $(srcdir)/setup.py install --prefix=$(DESTDIR)$(prefix)
+else
+	$(PYTHON) $(srcdir)/setup.py install --prefix=$(DESTDIR)$(prefix)
+endif
+
+
+# setup.py doesn't (yet) support an uninstall command, so until it does, you 
+# must manually remove everything that was installed here. The following example
+# should remove a basic package installed via setup.py, but please double- and 
+# triple-check it so that you don't remove something you shouldn't!
+# Be sure to remove any extra files you install, such as binaries or documentation!
+uninstall: 
+	-rm -rvf $(pkgpythondir)
+	-rm -v $(pythondir)/$(PACKAGE_DISTNAME)-*.egg-info
+	-rm $(pythondir)/_gyoto$(PYTHON_EXTENSION_SUFFIX)
+	-rm $(pythondir)/gyoto.py
+	-rm $(pythondir)/gyoto.pyc
+
+
+# Just use the usual setup.py clean command
+clean:
+	$(PYTHON) setup.py clean
+	-rm -Rf build
+	-rm gyoto.py gyoto_wrap.cxx
+
+# Clean up the output of configure
+distclean: 
+	-rm -v $(builddir)/setup.py
+	-rm -v $(builddir)/Makefile
+
+# You can either use the setup.py sdist command or you can roll your own here
+dist:
+#	$(PYTHON) setup.py sdist
+	mkdir $(PACKAGE_DISTNAME)
+	cp -r $(DISTFILES) $(PACKAGE_DISTNAME)
+	tar -czf $(PACKAGE_DISTNAME).tar.gz $(PACKAGE_DISTNAME)
+	rm -rf $(PACKAGE_DISTNAME)
+
+# Use the setup.py check command
+check:
+	$(PYTHON) setup.py check
+
+# setup.py might complain if a directory doesn't exist so just in case, make the directory
+# here
+installdirs:
+	$(MKDIR_P) $(DESTDIR)$(pkgpythondir)
+
+
+# The following show how to install documentation. In this example,
+# docs are built from a separate Makefile contained in the docs
+# directory which uses the SPHINXBUILD variable to store the location
+# of the sphinx-build (Python doc tool) binary to use.
+
+# $(DESTDIR)$(infodir)/foo.info: docs/build/texinfo/foo.info
+# 	$(POST_INSTALL)
+# 	$(INSTALL_DATA) @< $(DESTDIR)$@
+# 	if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then
+# 		install-info --dir-file=$(DESTDIR)$(infodir)/dir \
+# 				$(DESTDIR)$(infodir)/foo.info;
+# 	else true; fi
+#
+# info: docs/build/texinfo/foo.info
+#
+# docs/build/texinfo/foo.info: $(wildcard docs/source/*)
+# ifneq ($(SPHINXBUILD),no)
+# 	$(MAKE) -C docs info SPHINXBUILD=$(SPHINXBUILD)
+# endif
+#
+#
+# install-html: html installdirs
+# 	$(INSTALL_DATA) docs/build/html/* $(DESTDIR)$(htmldir)
+#
+# html: docs/build/html/index.html
+#
+# docs/build/html/index.html: $(wildcard $(srcdir)/docs/source/*)
+# ifneq ($(SPHINXBUILD),no)
+# 	$(MAKE) -C docs html SPHINXBUILD=$(SPHINXBUILD)
+# endif
+#
+#
+# install-pdf: pdf installdirs
+# 	$(INSTALL_DATA) docs/build/latex/foo.pdf $(DESTDIR)$(pdfdir)
+#
+# pdf: docs/build/latex/Foo.pdf
+#
+# docs/build/latex/foo.pdf: $(wildcard $(srcdir)/docs/source/*)
+# ifneq ($(SPHINXBUILD),no)
+# 	$(MAKE) -C docs latexpdf SPHINXBUILD=$(SPHINXBUILD)
+# endif
+#
+#
+# install-dvi:
+#
+# dvi:
+#
+# install-ps:
+#
+# ps:
+
+
diff --git a/python/PKG-INFO b/python/PKG-INFO
new file mode 100644
index 0000000..f6bb945
--- /dev/null
+++ b/python/PKG-INFO
@@ -0,0 +1,6 @@
+Metadata-Version: 1.2
+Name: gyoto
+Version: 0.1
+Summary: The General relativitY Orbit Tracer of paris Observatory
+Home-page: http://gyoto.obspm.fr
+Author-email: gyoto at sympa.obspm.fr
diff --git a/python/gyoto.i b/python/gyoto.i
index d49a7d8..bd8459f 100644
--- a/python/gyoto.i
+++ b/python/gyoto.i
@@ -2,6 +2,7 @@
 
 %{
 #define SWIG_FILE_WITH_INIT
+  //#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
 #include "Python.h"
 #define GYOTO_NO_DEPRECATED
 #include "GyotoConfig.h"
diff --git a/python/numpy.i b/python/numpy.i
new file mode 100644
index 0000000..4de4a20
--- /dev/null
+++ b/python/numpy.i
@@ -0,0 +1,1579 @@
+/* -*- C -*-  (not really, but good for syntax highlighting) */
+#ifdef SWIGPYTHON
+
+%{
+#ifndef SWIG_FILE_WITH_INIT
+#  define NO_IMPORT_ARRAY
+#endif
+#include "stdio.h"
+#include <numpy/arrayobject.h>
+%}
+
+/**********************************************************************/
+
+/* The following code originally appeared in
+ * enthought/kiva/agg/src/numeric.i written by Eric Jones.  It was
+ * translated from C++ to C by John Hunter.  Bill Spotz has modified
+ * it to fix some minor bugs, upgrade from Numeric to numpy (all
+ * versions), add some comments and functionality, and convert from
+ * direct code insertion to SWIG fragments.
+ */
+
+%fragment("NumPy_Macros", "header")
+{
+/* Macros to extract array attributes.
+ */
+%#define is_array(a)            ((a) && PyArray_Check((PyArrayObject *)a))
+%#define array_type(a)          (int)(PyArray_TYPE(a))
+%#define array_numdims(a)       (((PyArrayObject *)a)->nd)
+%#define array_dimensions(a)    (((PyArrayObject *)a)->dimensions)
+%#define array_size(a,i)        (((PyArrayObject *)a)->dimensions[i])
+%#define array_data(a)          (((PyArrayObject *)a)->data)
+%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a))
+%#define array_is_native(a)     (PyArray_ISNOTSWAPPED(a))
+%#define array_is_fortran(a)    (PyArray_ISFORTRAN(a))
+}
+
+/**********************************************************************/
+
+%fragment("NumPy_Utilities", "header")
+{
+  /* Given a PyObject, return a string describing its type.
+   */
+  const char* pytype_string(PyObject* py_obj) {
+    if (py_obj == NULL          ) return "C NULL value";
+    if (py_obj == Py_None       ) return "Python None" ;
+    if (PyCallable_Check(py_obj)) return "callable"    ;
+    if (PyString_Check(  py_obj)) return "string"      ;
+    if (PyInt_Check(     py_obj)) return "int"         ;
+    if (PyFloat_Check(   py_obj)) return "float"       ;
+    if (PyDict_Check(    py_obj)) return "dict"        ;
+    if (PyList_Check(    py_obj)) return "list"        ;
+    if (PyTuple_Check(   py_obj)) return "tuple"       ;
+    if (PyModule_Check(  py_obj)) return "module"      ;
+%#if PY_MAJOR_VERSION < 3
+    if (PyFile_Check(    py_obj)) return "file"        ;
+    if (PyInstance_Check(py_obj)) return "instance"    ;
+%#endif
+
+    return "unkown type";
+  }
+
+  /* Given a NumPy typecode, return a string describing the type.
+   */
+  const char* typecode_string(int typecode) {
+    static const char* type_names[25] = {"bool", "byte", "unsigned byte",
+                                   "short", "unsigned short", "int",
+                                   "unsigned int", "long", "unsigned long",
+                                   "long long", "unsigned long long",
+                                   "float", "double", "long double",
+                                   "complex float", "complex double",
+                                   "complex long double", "object",
+                                   "string", "unicode", "void", "ntypes",
+                                   "notype", "char", "unknown"};
+    return typecode < 24 ? type_names[typecode] : type_names[24];
+  }
+
+  /* Make sure input has correct numpy type.  Allow character and byte
+   * to match.  Also allow int and long to match.  This is deprecated.
+   * You should use PyArray_EquivTypenums() instead.
+   */
+  int type_match(int actual_type, int desired_type) {
+    return PyArray_EquivTypenums(actual_type, desired_type);
+  }
+}
+
+/**********************************************************************/
+
+%fragment("NumPy_Object_to_Array", "header",
+          fragment="NumPy_Backward_Compatibility",
+          fragment="NumPy_Macros",
+          fragment="NumPy_Utilities")
+{
+  /* Given a PyObject pointer, cast it to a PyArrayObject pointer if
+   * legal.  If not, set the python error string appropriately and
+   * return NULL.
+   */
+  PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode)
+  {
+    PyArrayObject* ary = NULL;
+    if (is_array(input) && (typecode == NPY_NOTYPE ||
+                            PyArray_EquivTypenums(array_type(input), typecode)))
+    {
+      ary = (PyArrayObject*) input;
+    }
+    else if is_array(input)
+    {
+      const char* desired_type = typecode_string(typecode);
+      const char* actual_type  = typecode_string(array_type(input));
+      PyErr_Format(PyExc_TypeError,
+                   "Array of type '%s' required.  Array of type '%s' given",
+                   desired_type, actual_type);
+      ary = NULL;
+    }
+    else
+    {
+      const char * desired_type = typecode_string(typecode);
+      const char * actual_type  = pytype_string(input);
+      PyErr_Format(PyExc_TypeError,
+                   "Array of type '%s' required.  A '%s' was given",
+                   desired_type, actual_type);
+      ary = NULL;
+    }
+    return ary;
+  }
+
+  /* Convert the given PyObject to a NumPy array with the given
+   * typecode.  On success, return a valid PyArrayObject* with the
+   * correct type.  On failure, the python error string will be set and
+   * the routine returns NULL.
+   */
+  PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode,
+                                               int* is_new_object)
+  {
+    PyArrayObject* ary = NULL;
+    PyObject* py_obj;
+    if (is_array(input) && (typecode == NPY_NOTYPE ||
+                            PyArray_EquivTypenums(array_type(input),typecode)))
+    {
+      ary = (PyArrayObject*) input;
+      *is_new_object = 0;
+    }
+    else
+    {
+      py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_DEFAULT);
+      /* If NULL, PyArray_FromObject will have set python error value.*/
+      ary = (PyArrayObject*) py_obj;
+      *is_new_object = 1;
+    }
+    return ary;
+  }
+
+  /* Given a PyArrayObject, check to see if it is contiguous.  If so,
+   * return the input pointer and flag it as not a new object.  If it is
+   * not contiguous, create a new PyArrayObject using the original data,
+   * flag it as a new object and return the pointer.
+   */
+  PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object,
+                                 int min_dims, int max_dims)
+  {
+    PyArrayObject* result;
+    if (array_is_contiguous(ary))
+    {
+      result = ary;
+      *is_new_object = 0;
+    }
+    else
+    {
+      result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary,
+                                                             array_type(ary),
+                                                             min_dims,
+                                                             max_dims);
+      *is_new_object = 1;
+    }
+    return result;
+  }
+
+  /* Given a PyArrayObject, check to see if it is Fortran-contiguous.
+   * If so, return the input pointer, but do not flag it as not a new
+   * object.  If it is not Fortran-contiguous, create a new
+   * PyArrayObject using the original data, flag it as a new object
+   * and return the pointer.
+   */
+  PyArrayObject* make_fortran(PyArrayObject* ary, int* is_new_object,
+                              int min_dims, int max_dims)
+  {
+    PyArrayObject* result;
+    if (array_is_fortran(ary))
+    {
+      result = ary;
+      *is_new_object = 0;
+    }
+    else
+    {
+      Py_INCREF(ary->descr);
+      result = (PyArrayObject*) PyArray_FromArray(ary, ary->descr, NPY_FORTRAN);
+      *is_new_object = 1;
+    }
+    return result;
+  }
+
+  /* Convert a given PyObject to a contiguous PyArrayObject of the
+   * specified type.  If the input object is not a contiguous
+   * PyArrayObject, a new one will be created and the new object flag
+   * will be set.
+   */
+  PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
+                                                          int typecode,
+                                                          int* is_new_object)
+  {
+    int is_new1 = 0;
+    int is_new2 = 0;
+    PyArrayObject* ary2;
+    PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode,
+                                                        &is_new1);
+    if (ary1)
+    {
+      ary2 = make_contiguous(ary1, &is_new2, 0, 0);
+      if ( is_new1 && is_new2)
+      {
+        Py_DECREF(ary1);
+      }
+      ary1 = ary2;
+    }
+    *is_new_object = is_new1 || is_new2;
+    return ary1;
+  }
+
+  /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the
+   * specified type.  If the input object is not a Fortran-ordered
+   * PyArrayObject, a new one will be created and the new object flag
+   * will be set.
+   */
+  PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input,
+                                                       int typecode,
+                                                       int* is_new_object)
+  {
+    int is_new1 = 0;
+    int is_new2 = 0;
+    PyArrayObject* ary2;
+    PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode,
+                                                        &is_new1);
+    if (ary1)
+    {
+      ary2 = make_fortran(ary1, &is_new2, 0, 0);
+      if (is_new1 && is_new2)
+      {
+        Py_DECREF(ary1);
+      }
+      ary1 = ary2;
+    }
+    *is_new_object = is_new1 || is_new2;
+    return ary1;
+  }
+
+} /* end fragment */
+
+
+/**********************************************************************/
+
+%fragment("NumPy_Array_Requirements", "header",
+          fragment="NumPy_Backward_Compatibility",
+          fragment="NumPy_Macros")
+{
+  /* Test whether a python object is contiguous.  If array is
+   * contiguous, return 1.  Otherwise, set the python error string and
+   * return 0.
+   */
+  int require_contiguous(PyArrayObject* ary)
+  {
+    int contiguous = 1;
+    if (!array_is_contiguous(ary))
+    {
+      PyErr_SetString(PyExc_TypeError,
+                      "Array must be contiguous.  A non-contiguous array was given");
+      contiguous = 0;
+    }
+    return contiguous;
+  }
+
+  /* Require that a numpy array is not byte-swapped.  If the array is
+   * not byte-swapped, return 1.  Otherwise, set the python error string
+   * and return 0.
+   */
+  int require_native(PyArrayObject* ary)
+  {
+    int native = 1;
+    if (!array_is_native(ary))
+    {
+      PyErr_SetString(PyExc_TypeError,
+                      "Array must have native byteorder.  "
+                      "A byte-swapped array was given");
+      native = 0;
+    }
+    return native;
+  }
+
+  /* Require the given PyArrayObject to have a specified number of
+   * dimensions.  If the array has the specified number of dimensions,
+   * return 1.  Otherwise, set the python error string and return 0.
+   */
+  int require_dimensions(PyArrayObject* ary, int exact_dimensions)
+  {
+    int success = 1;
+    if (array_numdims(ary) != exact_dimensions)
+    {
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have %d dimensions.  Given array has %d dimensions",
+                   exact_dimensions, array_numdims(ary));
+      success = 0;
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to have one of a list of specified
+   * number of dimensions.  If the array has one of the specified number
+   * of dimensions, return 1.  Otherwise, set the python error string
+   * and return 0.
+   */
+  int require_dimensions_n(PyArrayObject* ary, int* exact_dimensions, int n)
+  {
+    int success = 0;
+    int i;
+    char dims_str[255] = "";
+    char s[255];
+    for (i = 0; i < n && !success; i++)
+    {
+      if (array_numdims(ary) == exact_dimensions[i])
+      {
+        success = 1;
+      }
+    }
+    if (!success)
+    {
+      for (i = 0; i < n-1; i++)
+      {
+        sprintf(s, "%d, ", exact_dimensions[i]);
+        strcat(dims_str,s);
+      }
+      sprintf(s, " or %d", exact_dimensions[n-1]);
+      strcat(dims_str,s);
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have %s dimensions.  Given array has %d dimensions",
+                   dims_str, array_numdims(ary));
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to have a specified shape.  If the
+   * array has the specified shape, return 1.  Otherwise, set the python
+   * error string and return 0.
+   */
+  int require_size(PyArrayObject* ary, npy_intp* size, int n)
+  {
+    int i;
+    int success = 1;
+    int len;
+    char desired_dims[255] = "[";
+    char s[255];
+    char actual_dims[255] = "[";
+    for(i=0; i < n;i++)
+    {
+      if (size[i] != -1 &&  size[i] != array_size(ary,i))
+      {
+        success = 0;
+      }
+    }
+    if (!success)
+    {
+      for (i = 0; i < n; i++)
+      {
+        if (size[i] == -1)
+        {
+          sprintf(s, "*,");
+        }
+        else
+        {
+          sprintf(s, "%ld,", (long int)size[i]);
+        }
+        strcat(desired_dims,s);
+      }
+      len = strlen(desired_dims);
+      desired_dims[len-1] = ']';
+      for (i = 0; i < n; i++)
+      {
+        sprintf(s, "%ld,", (long int)array_size(ary,i));
+        strcat(actual_dims,s);
+      }
+      len = strlen(actual_dims);
+      actual_dims[len-1] = ']';
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have shape of %s.  Given array has shape of %s",
+                   desired_dims, actual_dims);
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to to be FORTRAN ordered.  If the
+   * the PyArrayObject is already FORTRAN ordered, do nothing.  Else,
+   * set the FORTRAN ordering flag and recompute the strides.
+   */
+  int require_fortran(PyArrayObject* ary)
+  {
+    int success = 1;
+    int nd = array_numdims(ary);
+    int i;
+    if (array_is_fortran(ary)) return success;
+    /* Set the FORTRAN ordered flag */
+    ary->flags = NPY_FARRAY;
+    /* Recompute the strides */
+    ary->strides[0] = ary->strides[nd-1];
+    for (i=1; i < nd; ++i)
+      ary->strides[i] = ary->strides[i-1] * array_size(ary,i-1);
+    return success;
+  }
+}
+
+/* Combine all NumPy fragments into one for convenience */
+%fragment("NumPy_Fragments", "header",
+          fragment="NumPy_Backward_Compatibility",
+          fragment="NumPy_Macros",
+          fragment="NumPy_Utilities",
+          fragment="NumPy_Object_to_Array",
+          fragment="NumPy_Array_Requirements") { }
+
+/* End John Hunter translation (with modifications by Bill Spotz)
+ */
+
+/* %numpy_typemaps() macro
+ *
+ * This macro defines a family of 41 typemaps that allow C arguments
+ * of the form
+ *
+ *     (DATA_TYPE IN_ARRAY1[ANY])
+ *     (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+ *     (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+ *
+ *     (DATA_TYPE IN_ARRAY2[ANY][ANY])
+ *     (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+ *     (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+ *
+ *     (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+ *     (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+ *     (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+ *
+ *     (DATA_TYPE INPLACE_ARRAY1[ANY])
+ *     (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+ *     (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+ *
+ *     (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ *     (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+ *     (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+ *
+ *     (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+ *     (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+ *     (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+ *
+ *     (DATA_TYPE ARGOUT_ARRAY1[ANY])
+ *     (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+ *     (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+ *
+ *     (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ *
+ *     (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+ *
+ *     (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+ *     (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+ *
+ *     (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ *     (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+ *     (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ *     (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+ *
+ *     (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ *     (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+ *     (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ *     (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+ *
+ * where "DATA_TYPE" is any type supported by the NumPy module, and
+ * "DIM_TYPE" is any int-like type suitable for specifying dimensions.
+ * The difference between "ARRAY" typemaps and "FARRAY" typemaps is
+ * that the "FARRAY" typemaps expect FORTRAN ordering of
+ * multidimensional arrays.  In python, the dimensions will not need
+ * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1"
+ * typemaps).  The IN_ARRAYs can be a numpy array or any sequence that
+ * can be converted to a numpy array of the specified type.  The
+ * INPLACE_ARRAYs must be numpy arrays of the appropriate type.  The
+ * ARGOUT_ARRAYs will be returned as new numpy arrays of the
+ * appropriate type.
+ *
+ * These typemaps can be applied to existing functions using the
+ * %apply directive.  For example:
+ *
+ *     %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)};
+ *     double prod(double* series, int length);
+ *
+ *     %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2)
+ *           {(int rows, int cols, double* matrix        )};
+ *     void floor(int rows, int cols, double* matrix, double f);
+ *
+ *     %apply (double IN_ARRAY3[ANY][ANY][ANY])
+ *           {(double tensor[2][2][2]         )};
+ *     %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
+ *           {(double low[2][2][2]                )};
+ *     %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
+ *           {(double upp[2][2][2]                )};
+ *     void luSplit(double tensor[2][2][2],
+ *                  double low[2][2][2],
+ *                  double upp[2][2][2]    );
+ *
+ * or directly with
+ *
+ *     double prod(double* IN_ARRAY1, int DIM1);
+ *
+ *     void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f);
+ *
+ *     void luSplit(double IN_ARRAY3[ANY][ANY][ANY],
+ *                  double ARGOUT_ARRAY3[ANY][ANY][ANY],
+ *                  double ARGOUT_ARRAY3[ANY][ANY][ANY]);
+ */
+
+%define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE)
+
+/************************/
+/* Input Array Typemaps */
+/************************/
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE IN_ARRAY1[ANY])
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE IN_ARRAY1[ANY])
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[1] = { $1_dim0 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 1) ||
+      !require_size(array, size, 1)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+  (DATA_TYPE IN_ARRAY1[ANY])
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[1] = { -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 1) ||
+      !require_size(array, size, 1)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[1] = {-1};
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 1) ||
+      !require_size(array, size, 1)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE IN_ARRAY2[ANY][ANY])
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE IN_ARRAY2[ANY][ANY])
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { $1_dim0, $1_dim1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+  (DATA_TYPE IN_ARRAY2[ANY][ANY])
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
+                                                &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* IN_ARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
+                                                &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* IN_FARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/***************************/
+/* In-Place Array Typemaps */
+/***************************/
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE INPLACE_ARRAY1[ANY])
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE INPLACE_ARRAY1[ANY])
+  (PyArrayObject* array=NULL)
+{
+  npy_intp size[1] = { $1_dim0 };
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) ||
+      !require_contiguous(array) || !require_native(array)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+  (PyArrayObject* array=NULL, int i=1)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,1) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = 1;
+  for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+  (PyArrayObject* array=NULL, int i=0)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,1) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = 1;
+  for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i);
+  $2 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+  (PyArrayObject* array=NULL)
+{
+  npy_intp size[2] = { $1_dim0, $1_dim1 };
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) ||
+      !require_contiguous(array) || !require_native(array)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
+      !require_native(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array)
+      || !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
+      !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+  (PyArrayObject* array=NULL)
+{
+  npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) ||
+      !require_contiguous(array) || !require_native(array)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
+      !require_native(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* INPLACE_ARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
+      !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* INPLACE_FARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array)
+      || !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+
+/*************************/
+/* Argout Array Typemaps */
+/*************************/
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY])
+ */
+%typemap(in,numinputs=0,
+         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+  (DATA_TYPE ARGOUT_ARRAY1[ANY])
+  (PyObject * array = NULL)
+{
+  npy_intp dims[1] = { $1_dim0 };
+  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE ARGOUT_ARRAY1[ANY])
+{
+  $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+ */
+%typemap(in,numinputs=1,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+  (PyObject * array = NULL)
+{
+  npy_intp dims[1];
+  if (!PyInt_Check($input))
+  {
+    const char* typestring = pytype_string($input);
+    PyErr_Format(PyExc_TypeError,
+                 "Int dimension expected.  '%s' given.",
+                 typestring);
+    SWIG_fail;
+  }
+  $2 = (DIM_TYPE) PyInt_AsLong($input);
+  dims[0] = (npy_intp) $2;
+  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+{
+  $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+ */
+%typemap(in,numinputs=1,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+  (PyObject * array = NULL)
+{
+  npy_intp dims[1];
+  if (!PyInt_Check($input))
+  {
+    const char* typestring = pytype_string($input);
+    PyErr_Format(PyExc_TypeError,
+                 "Int dimension expected.  '%s' given.",
+                 typestring);
+    SWIG_fail;
+  }
+  $1 = (DIM_TYPE) PyInt_AsLong($input);
+  dims[0] = (npy_intp) $1;
+  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $2 = (DATA_TYPE*) array_data(array);
+}
+%typemap(argout)
+  (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+{
+  $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ */
+%typemap(in,numinputs=0,
+         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+  (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+  (PyObject * array = NULL)
+{
+  npy_intp dims[2] = { $1_dim0, $1_dim1 };
+  array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+{
+  $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+ */
+%typemap(in,numinputs=0,
+         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+  (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+  (PyObject * array = NULL)
+{
+  npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 };
+  array = PyArray_SimpleNew(3, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+{
+  $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/*****************************/
+/* Argoutview Array Typemaps */
+/*****************************/
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1    )
+  (DATA_TYPE*  data_temp        , DIM_TYPE  dim_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+{
+  npy_intp dims[1] = { *$2 };
+  PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DATA_TYPE** ARGOUTVIEW_ARRAY1)
+  (DIM_TYPE  dim_temp, DATA_TYPE*  data_temp        )
+{
+  $1 = &dim_temp;
+  $2 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+{
+  npy_intp dims[1] = { *$1 };
+  PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
+  (DATA_TYPE*  data_temp        , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+{
+  npy_intp dims[2] = { *$2, *$3 };
+  PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEW_ARRAY2)
+  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp        )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+{
+  npy_intp dims[2] = { *$1, *$2 };
+  PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
+  (DATA_TYPE*  data_temp        , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+{
+  npy_intp dims[2] = { *$2, *$3 };
+  PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject * array = (PyArrayObject*) obj;
+  if (!array || !require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEW_FARRAY2)
+  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp        )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+{
+  npy_intp dims[2] = { *$1, *$2 };
+  PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+  PyArrayObject * array = (PyArrayObject*) obj;
+  if (!array || !require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+  (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+  npy_intp dims[3] = { *$2, *$3, *$4 };
+  PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
+                      DATA_TYPE** ARGOUTVIEW_ARRAY3)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp)
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+{
+  npy_intp dims[3] = { *$1, *$2, *$3 };
+  PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+  (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+  npy_intp dims[3] = { *$2, *$3, *$4 };
+  PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject * array = (PyArrayObject*) obj;
+  if (!array || require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
+                      DATA_TYPE** ARGOUTVIEW_FARRAY3)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp)
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+{
+  npy_intp dims[3] = { *$1, *$2, *$3 };
+  PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
+  PyArrayObject * array = (PyArrayObject*) obj;
+  if (!array || require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+%enddef    /* %numpy_typemaps() macro */
+/* *************************************************************** */
+
+/* Concrete instances of the %numpy_typemaps() macro: Each invocation
+ * below applies all of the typemaps above to the specified data type.
+ */
+%numpy_typemaps(signed char       , NPY_BYTE     , int)
+%numpy_typemaps(unsigned char     , NPY_UBYTE    , int)
+%numpy_typemaps(short             , NPY_SHORT    , int)
+%numpy_typemaps(unsigned short    , NPY_USHORT   , int)
+%numpy_typemaps(int               , NPY_INT      , int)
+%numpy_typemaps(unsigned int      , NPY_UINT     , int)
+%numpy_typemaps(long              , NPY_LONG     , int)
+%numpy_typemaps(unsigned long     , NPY_ULONG    , int)
+%numpy_typemaps(long long         , NPY_LONGLONG , int)
+%numpy_typemaps(unsigned long long, NPY_ULONGLONG, int)
+%numpy_typemaps(float             , NPY_FLOAT    , int)
+%numpy_typemaps(double            , NPY_DOUBLE   , int)
+
+/* ***************************************************************
+ * The follow macro expansion does not work, because C++ bool is 4
+ * bytes and NPY_BOOL is 1 byte
+ *
+ *    %numpy_typemaps(bool, NPY_BOOL, int)
+ */
+
+/* ***************************************************************
+ * On my Mac, I get the following warning for this macro expansion:
+ * 'swig/python detected a memory leak of type 'long double *', no destructor found.'
+ *
+ *    %numpy_typemaps(long double, NPY_LONGDOUBLE, int)
+ */
+
+/* ***************************************************************
+ * Swig complains about a syntax error for the following macro
+ * expansions:
+ *
+ *    %numpy_typemaps(complex float,  NPY_CFLOAT , int)
+ *
+ *    %numpy_typemaps(complex double, NPY_CDOUBLE, int)
+ *
+ *    %numpy_typemaps(complex long double, NPY_CLONGDOUBLE, int)
+ */
+
+#endif /* SWIGPYTHON */
diff --git a/python/setup.py.in b/python/setup.py.in
new file mode 100644
index 0000000..f2b540b
--- /dev/null
+++ b/python/setup.py.in
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+# setup.py.in.distutils
+#
+# Copyright 2012, 2013 Brandon Invergo <brandon at invergo.net>
+# Copyright 2014 Thibaut Paumard
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.  This file is offered as-is,
+# without any warranty.
+
+
+from distutils.core import setup, Extension
+import platform
+
+import numpy
+try:
+    numpy_include = numpy.get_include()
+except AttributeError:
+    numpy_include = numpy.get_numpy_include()
+
+
+if platform.system() == 'Linux':
+    doc_dir = '@prefix@/share/doc/@PACKAGE_TARNAME@'
+else:
+    try:
+        from win32com.shell import shellcon, shell
+        homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)
+        appdir = '@PACKAGE_TARNAME@'
+        doc_dir = os.path.join(homedir, appdir)
+    except:
+        pass
+
+gyoto_module = Extension('_gyoto',
+                         sources=['gyoto_wrap.cxx', 'gyoto.cxx'],
+                         include_dirs=[numpy_include]
+                         )
+
+setup(name='@PACKAGE_NAME@',
+      version='@PACKAGE_VERSION@',
+      author_email='@PACKAGE_BUGREPORT@',
+      py_modules=["gyoto"],
+      ext_modules=[gyoto_module]
+     )

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/gyoto.git



More information about the Debian-astro-commits mailing list