From: Mattia Rizzolo <mattia@debian.org>
Date: Fri, 27 May 2016 11:22:08 +0000
Subject: use pkg-config to look up the python2 include paths.

Forwarded: no
Last-Update: 2019-10-09

sysconfig.get_path("include") returns /usr/local/include/python2.7, which is
not what we want

Signed-off-by: Boyuan Yang <byang@debian.org>
---
 Makefile.am  | 2 +-
 configure.ac | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 080f97e..4d577a2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,7 +10,7 @@ HGTAG = 'libuser-$(VERSION)'
 
 AM_CPPFLAGS = $(GOBJECT_CFLAGS)
 LOCALEDIR_CPPFLAGS = -DLOCALEDIR='"$(localedir)"'
-PYTHON_CPPFLAGS = -I$(PYINCLUDEDIR)
+PYTHON_CPPFLAGS = $(PYINCLUDEDIR)
 
 AM_TESTS_ENVIRONMENT = PYTHON=$(PYTHON); export PYTHON;
 # Ignore possibly lost, there are too many due to Python.  --gen-suppressions
diff --git a/configure.ac b/configure.ac
index 1ded1a2..13d4b82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,6 +97,7 @@ if test x$sasl != xno ; then
 fi
 AM_CONDITIONAL([SASL], [test $build_sasl = yes])
 
+: "${PKG_CONFIG:=pkg-config}"
 AC_ARG_WITH([python],
 	    AS_HELP_STRING([--with-python],
 			   [build Python modules (default is YES)]), [],
@@ -104,7 +105,7 @@ AC_ARG_WITH([python],
 AM_CONDITIONAL([WITH_PYTHON], [test $with_python != no])
 if test $with_python != no ; then
    AM_PATH_PYTHON
-   PYINCLUDEDIR=`$PYTHON -c 'import sysconfig; print(sysconfig.get_path("include"))'`
+   PYINCLUDEDIR=`$PKG_CONFIG --cflags-only-I python`
 fi
 AC_SUBST(PYINCLUDEDIR)
 
