From b11465f53e03af484254c063b1fb5d4cb07df1be Mon Sep 17 00:00:00 2001
From: Kevin Brubeck Unhammer <unhammer@fsfe.org>
Date: Wed, 26 Feb 2020 10:17:41 +0100
Subject: [PATCH] Use python3-config --includes instead of get_python_inc()

Fix #39 - Python.h check is wrong for Python 3.8
---
 configure.ac | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1043ddb..7173973 100644
--- a/configure.ac
+++ b/configure.ac
@@ -144,12 +144,16 @@ AS_IF([test ! "$SWIG"],
 dnl =================
 dnl Checks for Python
 dnl =================
+
+dnl The test must instead add the result of `python3-config --includes` to the build flags and only `#include <Python.h>`
+
 AM_PATH_PYTHON([3.0],
                [],
                [AC_MSG_WARN([Python not found. Python is required to build divvun-gramcheck python bindings.])])
 AS_IF([test "$PYTHON" != :],
-      [python_include_path=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_inc());"`
-       AC_CHECK_HEADERS([${python_include_path}/Python.h],
+      [AC_SUBST(PYTHONINCLUDE,["`python3-config --includes`"])
+       CPPFLAGS="$CPPFLAGS $PYTHONINCLUDE"
+       AC_CHECK_HEADERS([Python.h],
                         [have_python_header=true],
                         [AC_MSG_WARN([Python.h header file not found. Python development files are required to build the divvun-gramcheck python bindings.])],
                         [])])