diff --git a/configure.ac b/configure.ac
index bb535b82cb28a611dbd4b5f572d685eff86e714c..03783f01ba136cac1a4c8fc3acc9d6b16a10ff09 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,6 +78,38 @@ if test "$enable_ipo" = "yes"; then
    fi
 fi
 
+# Compiling with Python wrapper
+AC_ARG_WITH([python],
+    [AS_HELP_STRING([--with-python=PATH],
+        [Root directory of python3]
+    )],
+    [],
+    [with_python="no"]
+)
+
+have_python="no"
+if test "x$with_python" != "xno"; then
+   if test "x$with_python" != "xyes" -a "x$with_python" != "x"; then
+     PYTHON_INCS="-I$with_python/include/python3.6m/"
+   else
+     PYTHON_INCS=""
+   fi
+
+   OLD_CPPFLAGS="$CPPFLAGS"
+
+   CPPFLAGS="$CPPFLAGS $PYTHON_INCS"
+   
+   have_python="yes"
+   AC_SUBST([PYTHON_INCS])
+   AC_CHECK_HEADER(
+     Python.h,
+     AC_DEFINE([SWIFT_PYTHON_WRAPPER],1,[Enable the python wrapper]),
+     AC_MSG_ERROR(something is wrong with the python library! PYTHON_INCS=$PYTHON_INCS)
+   )
+   CPPFLAGS="$OLD_CPPFLAGS"
+fi
+
+
 # Check for MPI. Need to do this before characterising the compiler (C99 mode),
 # as this changes the compiler.
 # We should consider using AX_PROG_CC_MPI to replace AC_PROG_CC when compiling
diff --git a/src/Makefile.am b/src/Makefile.am
index 7fc5981ebdf4e6d7a2bd28a74203f2e7b2fabd27..42c30883e1f6ac18128ef9c2bc49876a1226347b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,7 +16,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Add the debug flag to the whole thing
-AM_CFLAGS = $(HDF5_CPPFLAGS)
+AM_CFLAGS = $(HDF5_CPPFLAGS) $(PYTHON_INCS)
 
 # Assign a "safe" version number
 AM_LDFLAGS = $(HDF5_LDFLAGS) $(FFTW_LIBS) -version-info 0:0:0