1diff --git a/m4/ax_python_devel.m4 b/m4/ax_python_devel.m4
2--- a/m4/ax_python_devel.m4
3+++ b/m4/ax_python_devel.m4
4@@ -1,5 +1,5 @@
5 # ===========================================================================
6-# https://www.gnu.org/software/autoconf-archive/ax_python_devel.html
7+# https://www.gnu.org/software/autoconf-archive/ax_python_devel.html
8 # ===========================================================================
9 #
10 # SYNOPSIS
11@@ -12,8 +12,8 @@
12 # in your configure.ac.
13 #
14 # This macro checks for Python and tries to get the include path to
15-# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS)
16-# output variables. It also exports $(PYTHON_EXTRA_LIBS) and
17+# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LIBS) output
18+# variables. It also exports $(PYTHON_EXTRA_LIBS) and
19 # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code.
20 #
21 # You can search for some particular version of Python by passing a
22@@ -67,7 +67,7 @@
23 # modified version of the Autoconf Macro, you may extend this special
24 # exception to the GPL to apply to your modified version as well.
25
26-#serial 17
27+#serial 23
28
29 AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL])
30 AC_DEFUN([AX_PYTHON_DEVEL],[
31@@ -99,7 +99,7 @@
32 This version of the AC@&t@_PYTHON_DEVEL macro
33 doesn't work properly with versions of Python before
34 2.1.0. You may need to re-run configure, setting the
35-variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
36+variables PYTHON_CPPFLAGS, PYTHON_LIBS, PYTHON_SITE_PKG,
37 PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
38 Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
39 to something else than an empty string.
40@@ -135,16 +135,25 @@
41 #
42 # Check if you have distutils, else fail
43 #
44- AC_MSG_CHECKING([for the distutils Python package])
45- ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
46- if test -z "$ac_distutils_result"; then
47+ AC_MSG_CHECKING([for the sysconfig Python package])
48+ ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1`
49+ if test $? -eq 0; then
50 AC_MSG_RESULT([yes])
51+ IMPORT_SYSCONFIG="import sysconfig"
52 else
53 AC_MSG_RESULT([no])
54- AC_MSG_ERROR([cannot import Python module "distutils".
55+
56+ AC_MSG_CHECKING([for the distutils Python package])
57+ ac_sysconfig_result=`$PYTHON -c "from distutils import sysconfig" 2>&1`
58+ if test $? -eq 0; then
59+ AC_MSG_RESULT([yes])
60+ IMPORT_SYSCONFIG="from distutils import sysconfig"
61+ else
62+ AC_MSG_ERROR([cannot import Python module "distutils".
63 Please check your Python installation. The error was:
64-$ac_distutils_result])
65- PYTHON_VERSION=""
66+$ac_sysconfig_result])
67+ PYTHON_VERSION=""
68+ fi
69 fi
70
71 #
72@@ -152,10 +161,19 @@
73 #
74 AC_MSG_CHECKING([for Python include path])
75 if test -z "$PYTHON_CPPFLAGS"; then
76- python_path=`$PYTHON -c "import distutils.sysconfig; \
77- print (distutils.sysconfig.get_python_inc ());"`
78- plat_python_path=`$PYTHON -c "import distutils.sysconfig; \
79- print (distutils.sysconfig.get_python_inc (plat_specific=1));"`
80+ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
81+ # sysconfig module has different functions
82+ python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
83+ print (sysconfig.get_path ('include'));"`
84+ plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
85+ print (sysconfig.get_path ('platinclude'));"`
86+ else
87+ # old distutils way
88+ python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
89+ print (sysconfig.get_python_inc ());"`
90+ plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
91+ print (sysconfig.get_python_inc (plat_specific=1));"`
92+ fi
93 if test -n "${python_path}"; then
94 if test "${plat_python_path}" != "${python_path}"; then
95 python_path="-I$python_path -I$plat_python_path"
96@@ -172,14 +190,14 @@
97 # Check for Python library path
98 #
99 AC_MSG_CHECKING([for Python library path])
100- if test -z "$PYTHON_LDFLAGS"; then
101+ if test -z "$PYTHON_LIBS"; then
102 # (makes two attempts to ensure we've got a version number
103 # from the interpreter)
104 ac_python_version=`cat<<EOD | $PYTHON -
105
106 # join all versioning strings, on some systems
107 # major/minor numbers could be in different list elements
108-from distutils.sysconfig import *
109+from sysconfig import *
110 e = get_config_var('VERSION')
111 if e is not None:
112 print(e)
113@@ -197,7 +215,7 @@
114 # Make the versioning information available to the compiler
115
116 # JW: We don't need it and it interferes with the hack
117- # to detect multiple Pyhton versions
118+ # to detect multiple Python versions
119 #AC_DEFINE_UNQUOTED([HAVE_PYTHON], ["$ac_python_version"],
120 # [If available, contains the Python version number currently in use.])
121
122@@ -205,8 +223,8 @@
123 ac_python_libdir=`cat<<EOD | $PYTHON -
124
125 # There should be only one
126-import distutils.sysconfig
127-e = distutils.sysconfig.get_config_var('LIBDIR')
128+$IMPORT_SYSCONFIG
129+e = sysconfig.get_config_var('LIBDIR')
130 if e is not None:
131 print (e)
132 EOD`
133@@ -214,8 +232,8 @@
134 # Now, for the library:
135 ac_python_library=`cat<<EOD | $PYTHON -
136
137-import distutils.sysconfig
138-c = distutils.sysconfig.get_config_vars()
139+$IMPORT_SYSCONFIG
140+c = sysconfig.get_config_vars()
141 if 'LDVERSION' in c:
142 print ('python'+c[['LDVERSION']])
143 else:
144@@ -230,44 +248,67 @@
145 then
146 # use the official shared library
147 ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
148- PYTHON_LDFLAGS="-L$ac_python_libdir -l$ac_python_library"
149+ PYTHON_LIBS="-L$ac_python_libdir -l$ac_python_library"
150 else
151 # old way: use libpython from python_configdir
152 ac_python_libdir=`$PYTHON -c \
153- "from distutils.sysconfig import get_python_lib as f; \
154+ "from sysconfig import get_python_lib as f; \
155 import os; \
156 print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
157- PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
158+ PYTHON_LIBS="-L$ac_python_libdir -lpython$ac_python_version"
159 fi
160
161- if test -z "PYTHON_LDFLAGS"; then
162+ if test -z "PYTHON_LIBS"; then
163 AC_MSG_ERROR([
164 Cannot determine location of your Python DSO. Please check it was installed with
165- dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand.
166+ dynamic libraries enabled, or try setting PYTHON_LIBS by hand.
167 ])
168 fi
169 fi
170- AC_MSG_RESULT([$PYTHON_LDFLAGS])
171- AC_SUBST([PYTHON_LDFLAGS])
172+ AC_MSG_RESULT([$PYTHON_LIBS])
173+ AC_SUBST([PYTHON_LIBS])
174
175 #
176 # Check for site packages
177 #
178 AC_MSG_CHECKING([for Python site-packages path])
179 if test -z "$PYTHON_SITE_PKG"; then
180- PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
181- print (distutils.sysconfig.get_python_lib(0,0));"`
182+ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
183+ PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
184+ print (sysconfig.get_path('purelib'));"`
185+ else
186+ # distutils.sysconfig way
187+ PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
188+ print (sysconfig.get_python_lib(0,0));"`
189+ fi
190 fi
191 AC_MSG_RESULT([$PYTHON_SITE_PKG])
192 AC_SUBST([PYTHON_SITE_PKG])
193
194+ #
195+ # Check for platform-specific site packages
196+ #
197+ AC_MSG_CHECKING([for Python platform specific site-packages path])
198+ if test -z "$PYTHON_SITE_PKG"; then
199+ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
200+ PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
201+ print (sysconfig.get_path('platlib'));"`
202+ else
203+ # distutils.sysconfig way
204+ PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
205+ print (sysconfig.get_python_lib(1,0));"`
206+ fi
207+ fi
208+ AC_MSG_RESULT([$PYTHON_PLATFORM_SITE_PKG])
209+ AC_SUBST([PYTHON_PLATFORM_SITE_PKG])
210+
211 #
212 # libraries which must be linked in when embedding
213 #
214 AC_MSG_CHECKING(python extra libraries)
215 if test -z "$PYTHON_EXTRA_LIBS"; then
216- PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
217- conf = distutils.sysconfig.get_config_var; \
218+ PYTHON_EXTRA_LIBS=`$PYTHON -c "$IMPORT_SYSCONFIG; \
219+ conf = sysconfig.get_config_var; \
220 print (conf('LIBS') + ' ' + conf('SYSLIBS'))"`
221 fi
222 AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
223@@ -278,8 +319,8 @@
224 #
225 AC_MSG_CHECKING(python extra linking flags)
226 if test -z "$PYTHON_EXTRA_LDFLAGS"; then
227- PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
228- conf = distutils.sysconfig.get_config_var; \
229+ PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "$IMPORT_SYSCONFIG; \
230+ conf = sysconfig.get_config_var; \
231 print (conf('LINKFORSHARED'))"`
232 fi
233 AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
234@@ -291,8 +332,10 @@
235 AC_MSG_CHECKING([consistency of all components of python development environment])
236 # save current global flags
237 ac_save_LIBS="$LIBS"
238+ ac_save_LDFLAGS="$LDFLAGS"
239 ac_save_CPPFLAGS="$CPPFLAGS"
240- LIBS="$ac_save_LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS $PYTHON_EXTRA_LIBS"
241+ LIBS="$ac_save_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYTHON_EXTRA_LIBS"
242+ LDFLAGS="$ac_save_LDFLAGS $PYTHON_EXTRA_LDFLAGS"
243 CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
244 AC_LANG_PUSH([C])
245 AC_LINK_IFELSE([
246@@ -303,15 +346,17 @@
247 # turn back to default flags
248 CPPFLAGS="$ac_save_CPPFLAGS"
249 LIBS="$ac_save_LIBS"
250+ LDFLAGS="$ac_save_LDFLAGS"
251
252 AC_MSG_RESULT([$pythonexists])
253
254 if test ! "x$pythonexists" = "xyes"; then
255+ # gpgme: only warn here, no error, as we are looking for multiple versions
256 AC_MSG_WARN([
257 Could not link test program to Python. Maybe the main Python library has been
258 installed in some non-standard library path. If so, pass it to configure,
259- via the LDFLAGS environment variable.
260- Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
261+ via the LIBS environment variable.
262+ Example: ./configure LIBS="-L/usr/non-standard-path/python/lib"
263 ============================================================================
264 You probably have to install the development version of the Python package
265 for your distribution. The exact name of this package varies among them.
266@@ -323,4 +368,4 @@
267 #
268 # all done!
269 #
270-])
271+])
272\ No newline at end of file
273