···11+diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
22+--- a/lang/python/Makefile.am
33++++ b/lang/python/Makefile.am
44+@@ -34,8 +34,8 @@
55+ .PHONY: prepare
66+ prepare: copystamp
77+88+-# For VPATH builds we need to copy some files because Python's
99+-# distutils are not VPATH-aware.
1010++# For VPATH builds we need to copy some files because Python
1111++# is not VPATH-aware.
1212+ copystamp:
1313+ ln -sf "$(top_srcdir)/src/data.h" .
1414+ ln -sf "$(top_builddir)/conf/config.h" .
1515+@@ -48,7 +48,7 @@
1616+ CFLAGS="$(CFLAGS)" \
1717+ srcdir="$(srcdir)" \
1818+ top_builddir="$(top_builddir)" \
1919+- $$PYTHON setup.py build --verbose --build-base="$$(basename "$${PYTHON}")-gpg" ; \
2020++ $$PYTHON -m pip --verbose install --no-index --no-build-isolation --root="$$(basename "$${PYTHON}")-gpg" ${srcdir} ; \
2121+ done
2222+2323+ python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
2424+@@ -57,8 +57,7 @@
2525+ CFLAGS="$(CFLAGS)" \
2626+ srcdir="$(srcdir)" \
2727+ top_builddir="$(top_builddir)" \
2828+- $(PYTHON) setup.py sdist --verbose --dist-dir=python$(PYTHON_VERSION)-gpg-dist \
2929+- --manifest=python$(PYTHON_VERSION)-gpg-dist/MANIFEST
3030++ $(PYTHON) -m build --sdist --outdir=python$(PYTHON_VERSION)-gpg-dist
3131+ gpgbin=gpgconf --list-components | grep OpenPGP | sed -e 's/gpg:OpenPGP://g'
3232+ $(gpgbin) --detach-sign --armor python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz
3333+3434+@@ -92,17 +91,16 @@
3535+ CFLAGS="$(CFLAGS)" \
3636+ srcdir="$(srcdir)" \
3737+ top_builddir="$(top_builddir)" \
3838+- $$PYTHON setup.py \
3939+- build \
4040+- --build-base="$$(basename "$${PYTHON}")-gpg" \
4141++ $$PYTHON -m pip --verbose \
4242+ install \
4343++ --no-index --no-build-isolation \
4444+ --prefix "$(DESTDIR)$(prefix)" \
4545+- --verbose ; \
4646++ ${srcdir} ; \
4747+ done
4848+4949+ uninstall-local:
5050+ set -x; GV=$$(echo $(VERSION) | tr - _); for PYTHON in $(PYTHONS); do \
5151+ PLATLIB="$(prefix)/$$("$${PYTHON}" -c 'import sysconfig, os; print(os.path.relpath(sysconfig.get_path("platlib", scheme="posix_prefix"), sysconfig.get_config_var("prefix")))')" ; \
5252+ rm -rf -- "$(DESTDIR)$${PLATLIB}/gpg" \
5353+- "$(DESTDIR)$${PLATLIB}"/gpg-$$GV-py*.egg-info ; \
5454++ "$(DESTDIR)$${PLATLIB}"/gpg-$$GV.dist-info ; \
5555+ done
5656+diff --git a/lang/python/doc/src/gpgme-python-howto.org b/lang/python/doc/src/gpgme-python-howto.org
5757+--- a/lang/python/doc/src/gpgme-python-howto.org
5858++++ b/lang/python/doc/src/gpgme-python-howto.org
5959+@@ -2945,7 +2945,7 @@
6060+ =setup.py= file which contains this:
6161+6262+ #+BEGIN_SRC python -i
6363+-from distutils.core import setup
6464++from setuptools import setup
6565+ from Cython.Build import cythonize
6666+6767+ setup(
6868+diff --git a/lang/python/examples/howto/advanced/cython/setup.py b/lang/python/examples/howto/advanced/cython/setup.py
6969+--- a/lang/python/examples/howto/advanced/cython/setup.py
7070++++ b/lang/python/examples/howto/advanced/cython/setup.py
7171+@@ -1,4 +1,4 @@
7272+-from distutils.core import setup
7373++from setuptools import setup
7474+ from Cython.Build import cythonize
7575+7676+ setup(
7777+diff --git a/lang/python/setup.py.in b/lang/python/setup.py.in
7878+--- a/lang/python/setup.py.in
7979++++ b/lang/python/setup.py.in
8080+@@ -18,8 +18,8 @@
8181+ # License along with this library; if not, write to the Free Software
8282+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8383+8484+-from distutils.core import setup, Extension
8585+-from distutils.command.build import build
8686++from setuptools import setup, Extension
8787++from setuptools.command.build import build
8888+8989+ import glob
9090+ import os
9191+@@ -225,9 +225,8 @@
9292+ build.run(self)
9393+9494+9595+-py3 = [] if sys.version_info.major < 3 else ['-py3']
9696+ swig_sources = []
9797+-swig_opts = ['-threads'] + py3 + extra_swig_opts
9898++swig_opts = ['-threads'] + extra_swig_opts
9999+ swige = Extension(
100100+ 'gpg._gpgme',
101101+ sources=swig_sources,
102102+diff --git a/m4/ax_python_devel.m4 b/m4/ax_python_devel.m4
103103+--- a/m4/ax_python_devel.m4
104104++++ b/m4/ax_python_devel.m4
105105+@@ -1,10 +1,10 @@
106106+ # ===========================================================================
107107+-# https://www.gnu.org/software/autoconf-archive/ax_python_devel.html
108108++# https://www.gnu.org/software/autoconf-archive/ax_python_devel.html
109109+ # ===========================================================================
110110+ #
111111+ # SYNOPSIS
112112+ #
113113+-# AX_PYTHON_DEVEL([version])
114114++# AX_PYTHON_DEVEL([version[,optional]])
115115+ #
116116+ # DESCRIPTION
117117+ #
118118+@@ -12,8 +12,8 @@
119119+ # in your configure.ac.
120120+ #
121121+ # This macro checks for Python and tries to get the include path to
122122+-# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS)
123123+-# output variables. It also exports $(PYTHON_EXTRA_LIBS) and
124124++# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LIBS) output
125125++# variables. It also exports $(PYTHON_EXTRA_LIBS) and
126126+ # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code.
127127+ #
128128+ # You can search for some particular version of Python by passing a
129129+@@ -23,6 +23,11 @@
130130+ # version number. Don't use "PYTHON_VERSION" for this: that environment
131131+ # variable is declared as precious and thus reserved for the end-user.
132132+ #
133133++# By default this will fail if it does not detect a development version of
134134++# python. If you want it to continue, set optional to true, like
135135++# AX_PYTHON_DEVEL([], [true]). The ax_python_devel_found variable will be
136136++# "no" if it fails.
137137++#
138138+ # This macro should work for all versions of Python >= 2.1.0. As an end
139139+ # user, you can disable the check for the python version by setting the
140140+ # PYTHON_NOVERSIONCHECK environment variable to something else than the
141141+@@ -67,10 +72,18 @@
142142+ # modified version of the Autoconf Macro, you may extend this special
143143+ # exception to the GPL to apply to your modified version as well.
144144+145145+-#serial 17
146146++#serial 36
147147+148148+ AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL])
149149+ AC_DEFUN([AX_PYTHON_DEVEL],[
150150++ # Get whether it's optional
151151++ if test -z "$2"; then
152152++ ax_python_devel_optional=false
153153++ else
154154++ ax_python_devel_optional=$2
155155++ fi
156156++ ax_python_devel_found=yes
157157++
158158+ #
159159+ # Allow the use of a (user set) custom python version
160160+ #
161161+@@ -81,81 +94,147 @@
162162+163163+ AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
164164+ if test -z "$PYTHON"; then
165165+- AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path])
166166++ AC_MSG_WARN([Cannot find python$PYTHON_VERSION in your system path])
167167++ if ! $ax_python_devel_optional; then
168168++ AC_MSG_ERROR([Giving up, python development not available])
169169++ fi
170170++ ax_python_devel_found=no
171171+ PYTHON_VERSION=""
172172+ fi
173173+174174+- #
175175+- # Check for a version of Python >= 2.1.0
176176+- #
177177+- AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
178178+- ac_supports_python_ver=`$PYTHON -c "import sys; \
179179++ if test $ax_python_devel_found = yes; then
180180++ #
181181++ # Check for a version of Python >= 2.1.0
182182++ #
183183++ AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
184184++ ac_supports_python_ver=`$PYTHON -c "import sys; \
185185+ ver = sys.version.split ()[[0]]; \
186186+ print (ver >= '2.1.0')"`
187187+- if test "$ac_supports_python_ver" != "True"; then
188188++ if test "$ac_supports_python_ver" != "True"; then
189189+ if test -z "$PYTHON_NOVERSIONCHECK"; then
190190+ AC_MSG_RESULT([no])
191191+- AC_MSG_FAILURE([
192192++ AC_MSG_WARN([
193193+ This version of the AC@&t@_PYTHON_DEVEL macro
194194+ doesn't work properly with versions of Python before
195195+ 2.1.0. You may need to re-run configure, setting the
196196+-variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
197197++variables PYTHON_CPPFLAGS, PYTHON_LIBS, PYTHON_SITE_PKG,
198198+ PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
199199+ Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
200200+ to something else than an empty string.
201201+ ])
202202++ if ! $ax_python_devel_optional; then
203203++ AC_MSG_FAILURE([Giving up])
204204++ fi
205205++ ax_python_devel_found=no
206206++ PYTHON_VERSION=""
207207+ else
208208+ AC_MSG_RESULT([skip at user request])
209209+ fi
210210+- else
211211++ else
212212+ AC_MSG_RESULT([yes])
213213++ fi
214214+ fi
215215+216216+- #
217217+- # if the macro parameter ``version'' is set, honour it
218218+- #
219219+- if test -n "$1"; then
220220++ if test $ax_python_devel_found = yes; then
221221++ #
222222++ # If the macro parameter ``version'' is set, honour it.
223223++ # A Python shim class, VPy, is used to implement correct version comparisons via
224224++ # string expressions, since e.g. a naive textual ">= 2.7.3" won't work for
225225++ # Python 2.7.10 (the ".1" being evaluated as less than ".3").
226226++ #
227227++ if test -n "$1"; then
228228+ AC_MSG_CHECKING([for a version of Python $1])
229229+- ac_supports_python_ver=`$PYTHON -c "import sys; \
230230+- ver = sys.version.split ()[[0]]; \
231231++ cat << EOF > ax_python_devel_vpy.py
232232++class VPy:
233233++ def vtup(self, s):
234234++ return tuple(map(int, s.strip().replace("rc", ".").split(".")))
235235++ def __init__(self):
236236++ import sys
237237++ self.vpy = tuple(sys.version_info)[[:3]]
238238++ def __eq__(self, s):
239239++ return self.vpy == self.vtup(s)
240240++ def __ne__(self, s):
241241++ return self.vpy != self.vtup(s)
242242++ def __lt__(self, s):
243243++ return self.vpy < self.vtup(s)
244244++ def __gt__(self, s):
245245++ return self.vpy > self.vtup(s)
246246++ def __le__(self, s):
247247++ return self.vpy <= self.vtup(s)
248248++ def __ge__(self, s):
249249++ return self.vpy >= self.vtup(s)
250250++EOF
251251++ ac_supports_python_ver=`$PYTHON -c "import ax_python_devel_vpy; \
252252++ ver = ax_python_devel_vpy.VPy(); \
253253+ print (ver $1)"`
254254++ rm -rf ax_python_devel_vpy*.py* __pycache__/ax_python_devel_vpy*.py*
255255+ if test "$ac_supports_python_ver" = "True"; then
256256+- AC_MSG_RESULT([yes])
257257++ AC_MSG_RESULT([yes])
258258+ else
259259+ AC_MSG_RESULT([no])
260260+- AC_MSG_ERROR([this package requires Python $1.
261261++ AC_MSG_WARN([this package requires Python $1.
262262+ If you have it installed, but it isn't the default Python
263263+ interpreter in your system path, please pass the PYTHON_VERSION
264264+ variable to configure. See ``configure --help'' for reference.
265265+ ])
266266++ if ! $ax_python_devel_optional; then
267267++ AC_MSG_ERROR([Giving up])
268268++ fi
269269++ ax_python_devel_found=no
270270+ PYTHON_VERSION=""
271271+ fi
272272++ fi
273273+ fi
274274+275275+- #
276276+- # Check if you have distutils, else fail
277277+- #
278278+- AC_MSG_CHECKING([for the distutils Python package])
279279+- ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
280280+- if test -z "$ac_distutils_result"; then
281281++ if test $ax_python_devel_found = yes; then
282282++ #
283283++ # Check if you have distutils, else fail
284284++ #
285285++ AC_MSG_CHECKING([for the sysconfig Python package])
286286++ ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1`
287287++ if test $? -eq 0; then
288288+ AC_MSG_RESULT([yes])
289289+- else
290290++ IMPORT_SYSCONFIG="import sysconfig"
291291++ else
292292+ AC_MSG_RESULT([no])
293293+- AC_MSG_ERROR([cannot import Python module "distutils".
294294++
295295++ AC_MSG_CHECKING([for the distutils Python package])
296296++ ac_sysconfig_result=`$PYTHON -c "from distutils import sysconfig" 2>&1`
297297++ if test $? -eq 0; then
298298++ AC_MSG_RESULT([yes])
299299++ IMPORT_SYSCONFIG="from distutils import sysconfig"
300300++ else
301301++ AC_MSG_WARN([cannot import Python module "distutils".
302302+ Please check your Python installation. The error was:
303303+-$ac_distutils_result])
304304+- PYTHON_VERSION=""
305305++$ac_sysconfig_result])
306306++ if ! $ax_python_devel_optional; then
307307++ AC_MSG_ERROR([Giving up])
308308++ fi
309309++ ax_python_devel_found=no
310310++ PYTHON_VERSION=""
311311++ fi
312312++ fi
313313+ fi
314314+315315+- #
316316+- # Check for Python include path
317317+- #
318318+- AC_MSG_CHECKING([for Python include path])
319319+- if test -z "$PYTHON_CPPFLAGS"; then
320320+- python_path=`$PYTHON -c "import distutils.sysconfig; \
321321+- print (distutils.sysconfig.get_python_inc ());"`
322322+- plat_python_path=`$PYTHON -c "import distutils.sysconfig; \
323323+- print (distutils.sysconfig.get_python_inc (plat_specific=1));"`
324324++ if test $ax_python_devel_found = yes; then
325325++ #
326326++ # Check for Python include path
327327++ #
328328++ AC_MSG_CHECKING([for Python include path])
329329++ if test -z "$PYTHON_CPPFLAGS"; then
330330++ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
331331++ # sysconfig module has different functions
332332++ python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
333333++ print (sysconfig.get_path ('include'));"`
334334++ plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
335335++ print (sysconfig.get_path ('platinclude'));"`
336336++ else
337337++ # old distutils way
338338++ python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
339339++ print (sysconfig.get_python_inc ());"`
340340++ plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
341341++ print (sysconfig.get_python_inc (plat_specific=1));"`
342342++ fi
343343+ if test -n "${python_path}"; then
344344+ if test "${plat_python_path}" != "${python_path}"; then
345345+ python_path="-I$python_path -I$plat_python_path"
346346+@@ -164,22 +243,22 @@
347347+ fi
348348+ fi
349349+ PYTHON_CPPFLAGS=$python_path
350350+- fi
351351+- AC_MSG_RESULT([$PYTHON_CPPFLAGS])
352352+- AC_SUBST([PYTHON_CPPFLAGS])
353353++ fi
354354++ AC_MSG_RESULT([$PYTHON_CPPFLAGS])
355355++ AC_SUBST([PYTHON_CPPFLAGS])
356356+357357+- #
358358+- # Check for Python library path
359359+- #
360360+- AC_MSG_CHECKING([for Python library path])
361361+- if test -z "$PYTHON_LDFLAGS"; then
362362++ #
363363++ # Check for Python library path
364364++ #
365365++ AC_MSG_CHECKING([for Python library path])
366366++ if test -z "$PYTHON_LIBS"; then
367367+ # (makes two attempts to ensure we've got a version number
368368+ # from the interpreter)
369369+ ac_python_version=`cat<<EOD | $PYTHON -
370370+371371+ # join all versioning strings, on some systems
372372+ # major/minor numbers could be in different list elements
373373+-from distutils.sysconfig import *
374374++from sysconfig import *
375375+ e = get_config_var('VERSION')
376376+ if e is not None:
377377+ print(e)
378378+@@ -190,7 +269,7 @@
379379+ ac_python_version=$PYTHON_VERSION
380380+ else
381381+ ac_python_version=`$PYTHON -c "import sys; \
382382+- print (sys.version[[:3]])"`
383383++ print ("%d.%d" % sys.version_info[[:2]])"`
384384+ fi
385385+ fi
386386+387387+@@ -205,8 +284,8 @@
388388+ ac_python_libdir=`cat<<EOD | $PYTHON -
389389+390390+ # There should be only one
391391+-import distutils.sysconfig
392392+-e = distutils.sysconfig.get_config_var('LIBDIR')
393393++$IMPORT_SYSCONFIG
394394++e = sysconfig.get_config_var('LIBDIR')
395395+ if e is not None:
396396+ print (e)
397397+ EOD`
398398+@@ -214,8 +293,8 @@
399399+ # Now, for the library:
400400+ ac_python_library=`cat<<EOD | $PYTHON -
401401+402402+-import distutils.sysconfig
403403+-c = distutils.sysconfig.get_config_vars()
404404++$IMPORT_SYSCONFIG
405405++c = sysconfig.get_config_vars()
406406+ if 'LDVERSION' in c:
407407+ print ('python'+c[['LDVERSION']])
408408+ else:
409409+@@ -230,97 +309,163 @@
410410+ then
411411+ # use the official shared library
412412+ ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
413413+- PYTHON_LDFLAGS="-L$ac_python_libdir -l$ac_python_library"
414414++ PYTHON_LIBS="-L$ac_python_libdir -l$ac_python_library"
415415+ else
416416+ # old way: use libpython from python_configdir
417417+ ac_python_libdir=`$PYTHON -c \
418418+- "from distutils.sysconfig import get_python_lib as f; \
419419++ "from sysconfig import get_python_lib as f; \
420420+ import os; \
421421+ print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
422422+- PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
423423++ PYTHON_LIBS="-L$ac_python_libdir -lpython$ac_python_version"
424424+ fi
425425+426426+- if test -z "PYTHON_LDFLAGS"; then
427427+- AC_MSG_ERROR([
428428++ if test -z "PYTHON_LIBS"; then
429429++ AC_MSG_WARN([
430430+ Cannot determine location of your Python DSO. Please check it was installed with
431431+- dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand.
432432++ dynamic libraries enabled, or try setting PYTHON_LIBS by hand.
433433+ ])
434434++ if ! $ax_python_devel_optional; then
435435++ AC_MSG_ERROR([Giving up])
436436++ fi
437437++ ax_python_devel_found=no
438438++ PYTHON_VERSION=""
439439+ fi
440440++ fi
441441+ fi
442442+- AC_MSG_RESULT([$PYTHON_LDFLAGS])
443443+- AC_SUBST([PYTHON_LDFLAGS])
444444+445445+- #
446446+- # Check for site packages
447447+- #
448448+- AC_MSG_CHECKING([for Python site-packages path])
449449+- if test -z "$PYTHON_SITE_PKG"; then
450450+- PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
451451+- print (distutils.sysconfig.get_python_lib(0,0));"`
452452+- fi
453453+- AC_MSG_RESULT([$PYTHON_SITE_PKG])
454454+- AC_SUBST([PYTHON_SITE_PKG])
455455++ if test $ax_python_devel_found = yes; then
456456++ AC_MSG_RESULT([$PYTHON_LIBS])
457457++ AC_SUBST([PYTHON_LIBS])
458458+459459+- #
460460+- # libraries which must be linked in when embedding
461461+- #
462462+- AC_MSG_CHECKING(python extra libraries)
463463+- if test -z "$PYTHON_EXTRA_LIBS"; then
464464+- PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
465465+- conf = distutils.sysconfig.get_config_var; \
466466++ #
467467++ # Check for site packages
468468++ #
469469++ AC_MSG_CHECKING([for Python site-packages path])
470470++ if test -z "$PYTHON_SITE_PKG"; then
471471++ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
472472++ PYTHON_SITE_PKG=`$PYTHON -c "
473473++$IMPORT_SYSCONFIG;
474474++if hasattr(sysconfig, 'get_default_scheme'):
475475++ scheme = sysconfig.get_default_scheme()
476476++else:
477477++ scheme = sysconfig._get_default_scheme()
478478++if scheme == 'posix_local':
479479++ # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/
480480++ scheme = 'posix_prefix'
481481++prefix = '$prefix'
482482++if prefix == 'NONE':
483483++ prefix = '$ac_default_prefix'
484484++sitedir = sysconfig.get_path('purelib', scheme, vars={'base': prefix})
485485++print(sitedir)"`
486486++ else
487487++ # distutils.sysconfig way
488488++ PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
489489++ print (sysconfig.get_python_lib(0,0));"`
490490++ fi
491491++ fi
492492++ AC_MSG_RESULT([$PYTHON_SITE_PKG])
493493++ AC_SUBST([PYTHON_SITE_PKG])
494494++
495495++ #
496496++ # Check for platform-specific site packages
497497++ #
498498++ AC_MSG_CHECKING([for Python platform specific site-packages path])
499499++ if test -z "$PYTHON_PLATFORM_SITE_PKG"; then
500500++ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
501501++ PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "
502502++$IMPORT_SYSCONFIG;
503503++if hasattr(sysconfig, 'get_default_scheme'):
504504++ scheme = sysconfig.get_default_scheme()
505505++else:
506506++ scheme = sysconfig._get_default_scheme()
507507++if scheme == 'posix_local':
508508++ # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/
509509++ scheme = 'posix_prefix'
510510++prefix = '$prefix'
511511++if prefix == 'NONE':
512512++ prefix = '$ac_default_prefix'
513513++sitedir = sysconfig.get_path('platlib', scheme, vars={'platbase': prefix})
514514++print(sitedir)"`
515515++ else
516516++ # distutils.sysconfig way
517517++ PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
518518++ print (sysconfig.get_python_lib(1,0));"`
519519++ fi
520520++ fi
521521++ AC_MSG_RESULT([$PYTHON_PLATFORM_SITE_PKG])
522522++ AC_SUBST([PYTHON_PLATFORM_SITE_PKG])
523523++
524524++ #
525525++ # libraries which must be linked in when embedding
526526++ #
527527++ AC_MSG_CHECKING(python extra libraries)
528528++ if test -z "$PYTHON_EXTRA_LIBS"; then
529529++ PYTHON_EXTRA_LIBS=`$PYTHON -c "$IMPORT_SYSCONFIG; \
530530++ conf = sysconfig.get_config_var; \
531531+ print (conf('LIBS') + ' ' + conf('SYSLIBS'))"`
532532+- fi
533533+- AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
534534+- AC_SUBST(PYTHON_EXTRA_LIBS)
535535++ fi
536536++ AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
537537++ AC_SUBST(PYTHON_EXTRA_LIBS)
538538+539539+- #
540540+- # linking flags needed when embedding
541541+- #
542542+- AC_MSG_CHECKING(python extra linking flags)
543543+- if test -z "$PYTHON_EXTRA_LDFLAGS"; then
544544+- PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
545545+- conf = distutils.sysconfig.get_config_var; \
546546++ #
547547++ # linking flags needed when embedding
548548++ #
549549++ AC_MSG_CHECKING(python extra linking flags)
550550++ if test -z "$PYTHON_EXTRA_LDFLAGS"; then
551551++ PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "$IMPORT_SYSCONFIG; \
552552++ conf = sysconfig.get_config_var; \
553553+ print (conf('LINKFORSHARED'))"`
554554+- fi
555555+- AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
556556+- AC_SUBST(PYTHON_EXTRA_LDFLAGS)
557557++ # Hack for macos, it sticks this in here.
558558++ PYTHON_EXTRA_LDFLAGS=`echo $PYTHON_EXTRA_LDFLAGS | sed 's/CoreFoundation.*$/CoreFoundation/'`
559559++ fi
560560++ AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
561561++ AC_SUBST(PYTHON_EXTRA_LDFLAGS)
562562+563563+- #
564564+- # final check to see if everything compiles alright
565565+- #
566566+- AC_MSG_CHECKING([consistency of all components of python development environment])
567567+- # save current global flags
568568+- ac_save_LIBS="$LIBS"
569569+- ac_save_CPPFLAGS="$CPPFLAGS"
570570+- LIBS="$ac_save_LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS $PYTHON_EXTRA_LIBS"
571571+- CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
572572+- AC_LANG_PUSH([C])
573573+- AC_LINK_IFELSE([
574574++ #
575575++ # final check to see if everything compiles alright
576576++ #
577577++ AC_MSG_CHECKING([consistency of all components of python development environment])
578578++ # save current global flags
579579++ ac_save_LIBS="$LIBS"
580580++ ac_save_LDFLAGS="$LDFLAGS"
581581++ ac_save_CPPFLAGS="$CPPFLAGS"
582582++ LIBS="$ac_save_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS"
583583++ LDFLAGS="$ac_save_LDFLAGS $PYTHON_EXTRA_LDFLAGS"
584584++ CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
585585++ AC_LANG_PUSH([C])
586586++ AC_LINK_IFELSE([
587587+ AC_LANG_PROGRAM([[#include <Python.h>]],
588588+ [[Py_Initialize();]])
589589+ ],[pythonexists=yes],[pythonexists=no])
590590+- AC_LANG_POP([C])
591591+- # turn back to default flags
592592+- CPPFLAGS="$ac_save_CPPFLAGS"
593593+- LIBS="$ac_save_LIBS"
594594++ AC_LANG_POP([C])
595595++ # turn back to default flags
596596++ CPPFLAGS="$ac_save_CPPFLAGS"
597597++ LIBS="$ac_save_LIBS"
598598++ LDFLAGS="$ac_save_LDFLAGS"
599599+600600+- AC_MSG_RESULT([$pythonexists])
601601++ AC_MSG_RESULT([$pythonexists])
602602+603603+- if test ! "x$pythonexists" = "xyes"; then
604604+- AC_MSG_WARN([
605605++ if test ! "x$pythonexists" = "xyes"; then
606606++ AC_MSG_WARN([
607607+ Could not link test program to Python. Maybe the main Python library has been
608608+ installed in some non-standard library path. If so, pass it to configure,
609609+- via the LDFLAGS environment variable.
610610+- Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
611611++ via the LIBS environment variable.
612612++ Example: ./configure LIBS="-L/usr/non-standard-path/python/lib"
613613+ ============================================================================
614614++ ERROR!
615615+ You probably have to install the development version of the Python package
616616+ for your distribution. The exact name of this package varies among them.
617617+ ============================================================================
618618+- ])
619619+- PYTHON_VERSION=""
620620++ ])
621621++ if ! $ax_python_devel_optional; then
622622++ AC_MSG_ERROR([Giving up])
623623++ fi
624624++ ax_python_devel_found=no
625625++ PYTHON_VERSION=""
626626++ fi
627627+ fi
628628+629629+ #
630630+ # all done!
631631+ #
632632+-])
633633++])
634634+\ No newline at end of file
635635+diff --git a/m4/python.m4 b/m4/python.m4
636636+--- a/m4/python.m4
637637++++ b/m4/python.m4
638638+@@ -41,7 +41,7 @@
639639+ m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
640640+ [python2 python2.7 dnl
641641+ python dnl
642642+- python3 python3.10 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4
643643++ python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4
644644+ ])
645645+646646+ AC_ARG_VAR([PYTHON], [the Python interpreter])
647647+
···11-diff --git a/m4/ax_python_devel.m4 b/m4/ax_python_devel.m4
22---- a/m4/ax_python_devel.m4
33-+++ b/m4/ax_python_devel.m4
44-@@ -1,5 +1,5 @@
55- # ===========================================================================
66--# https://www.gnu.org/software/autoconf-archive/ax_python_devel.html
77-+# https://www.gnu.org/software/autoconf-archive/ax_python_devel.html
88- # ===========================================================================
99- #
1010- # SYNOPSIS
1111-@@ -12,8 +12,8 @@
1212- # in your configure.ac.
1313- #
1414- # This macro checks for Python and tries to get the include path to
1515--# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS)
1616--# output variables. It also exports $(PYTHON_EXTRA_LIBS) and
1717-+# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LIBS) output
1818-+# variables. It also exports $(PYTHON_EXTRA_LIBS) and
1919- # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code.
2020- #
2121- # You can search for some particular version of Python by passing a
2222-@@ -67,7 +67,7 @@
2323- # modified version of the Autoconf Macro, you may extend this special
2424- # exception to the GPL to apply to your modified version as well.
2525-2626--#serial 17
2727-+#serial 23
2828-2929- AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL])
3030- AC_DEFUN([AX_PYTHON_DEVEL],[
3131-@@ -99,7 +99,7 @@
3232- This version of the AC@&t@_PYTHON_DEVEL macro
3333- doesn't work properly with versions of Python before
3434- 2.1.0. You may need to re-run configure, setting the
3535--variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
3636-+variables PYTHON_CPPFLAGS, PYTHON_LIBS, PYTHON_SITE_PKG,
3737- PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
3838- Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
3939- to something else than an empty string.
4040-@@ -135,16 +135,25 @@
4141- #
4242- # Check if you have distutils, else fail
4343- #
4444-- AC_MSG_CHECKING([for the distutils Python package])
4545-- ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
4646-- if test -z "$ac_distutils_result"; then
4747-+ AC_MSG_CHECKING([for the sysconfig Python package])
4848-+ ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1`
4949-+ if test $? -eq 0; then
5050- AC_MSG_RESULT([yes])
5151-+ IMPORT_SYSCONFIG="import sysconfig"
5252- else
5353- AC_MSG_RESULT([no])
5454-- AC_MSG_ERROR([cannot import Python module "distutils".
5555-+
5656-+ AC_MSG_CHECKING([for the distutils Python package])
5757-+ ac_sysconfig_result=`$PYTHON -c "from distutils import sysconfig" 2>&1`
5858-+ if test $? -eq 0; then
5959-+ AC_MSG_RESULT([yes])
6060-+ IMPORT_SYSCONFIG="from distutils import sysconfig"
6161-+ else
6262-+ AC_MSG_ERROR([cannot import Python module "distutils".
6363- Please check your Python installation. The error was:
6464--$ac_distutils_result])
6565-- PYTHON_VERSION=""
6666-+$ac_sysconfig_result])
6767-+ PYTHON_VERSION=""
6868-+ fi
6969- fi
7070-7171- #
7272-@@ -152,10 +161,19 @@
7373- #
7474- AC_MSG_CHECKING([for Python include path])
7575- if test -z "$PYTHON_CPPFLAGS"; then
7676-- python_path=`$PYTHON -c "import distutils.sysconfig; \
7777-- print (distutils.sysconfig.get_python_inc ());"`
7878-- plat_python_path=`$PYTHON -c "import distutils.sysconfig; \
7979-- print (distutils.sysconfig.get_python_inc (plat_specific=1));"`
8080-+ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
8181-+ # sysconfig module has different functions
8282-+ python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
8383-+ print (sysconfig.get_path ('include'));"`
8484-+ plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
8585-+ print (sysconfig.get_path ('platinclude'));"`
8686-+ else
8787-+ # old distutils way
8888-+ python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
8989-+ print (sysconfig.get_python_inc ());"`
9090-+ plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
9191-+ print (sysconfig.get_python_inc (plat_specific=1));"`
9292-+ fi
9393- if test -n "${python_path}"; then
9494- if test "${plat_python_path}" != "${python_path}"; then
9595- python_path="-I$python_path -I$plat_python_path"
9696-@@ -172,14 +190,14 @@
9797- # Check for Python library path
9898- #
9999- AC_MSG_CHECKING([for Python library path])
100100-- if test -z "$PYTHON_LDFLAGS"; then
101101-+ if test -z "$PYTHON_LIBS"; then
102102- # (makes two attempts to ensure we've got a version number
103103- # from the interpreter)
104104- ac_python_version=`cat<<EOD | $PYTHON -
105105-106106- # join all versioning strings, on some systems
107107- # major/minor numbers could be in different list elements
108108--from distutils.sysconfig import *
109109-+from sysconfig import *
110110- e = get_config_var('VERSION')
111111- if e is not None:
112112- print(e)
113113-@@ -197,7 +215,7 @@
114114- # Make the versioning information available to the compiler
115115-116116- # JW: We don't need it and it interferes with the hack
117117-- # to detect multiple Pyhton versions
118118-+ # to detect multiple Python versions
119119- #AC_DEFINE_UNQUOTED([HAVE_PYTHON], ["$ac_python_version"],
120120- # [If available, contains the Python version number currently in use.])
121121-122122-@@ -205,8 +223,8 @@
123123- ac_python_libdir=`cat<<EOD | $PYTHON -
124124-125125- # There should be only one
126126--import distutils.sysconfig
127127--e = distutils.sysconfig.get_config_var('LIBDIR')
128128-+$IMPORT_SYSCONFIG
129129-+e = sysconfig.get_config_var('LIBDIR')
130130- if e is not None:
131131- print (e)
132132- EOD`
133133-@@ -214,8 +232,8 @@
134134- # Now, for the library:
135135- ac_python_library=`cat<<EOD | $PYTHON -
136136-137137--import distutils.sysconfig
138138--c = distutils.sysconfig.get_config_vars()
139139-+$IMPORT_SYSCONFIG
140140-+c = sysconfig.get_config_vars()
141141- if 'LDVERSION' in c:
142142- print ('python'+c[['LDVERSION']])
143143- else:
144144-@@ -230,44 +248,67 @@
145145- then
146146- # use the official shared library
147147- ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
148148-- PYTHON_LDFLAGS="-L$ac_python_libdir -l$ac_python_library"
149149-+ PYTHON_LIBS="-L$ac_python_libdir -l$ac_python_library"
150150- else
151151- # old way: use libpython from python_configdir
152152- ac_python_libdir=`$PYTHON -c \
153153-- "from distutils.sysconfig import get_python_lib as f; \
154154-+ "from sysconfig import get_python_lib as f; \
155155- import os; \
156156- print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
157157-- PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
158158-+ PYTHON_LIBS="-L$ac_python_libdir -lpython$ac_python_version"
159159- fi
160160-161161-- if test -z "PYTHON_LDFLAGS"; then
162162-+ if test -z "PYTHON_LIBS"; then
163163- AC_MSG_ERROR([
164164- Cannot determine location of your Python DSO. Please check it was installed with
165165-- dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand.
166166-+ dynamic libraries enabled, or try setting PYTHON_LIBS by hand.
167167- ])
168168- fi
169169- fi
170170-- AC_MSG_RESULT([$PYTHON_LDFLAGS])
171171-- AC_SUBST([PYTHON_LDFLAGS])
172172-+ AC_MSG_RESULT([$PYTHON_LIBS])
173173-+ AC_SUBST([PYTHON_LIBS])
174174-175175- #
176176- # Check for site packages
177177- #
178178- AC_MSG_CHECKING([for Python site-packages path])
179179- if test -z "$PYTHON_SITE_PKG"; then
180180-- PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
181181-- print (distutils.sysconfig.get_python_lib(0,0));"`
182182-+ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
183183-+ PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
184184-+ print (sysconfig.get_path('purelib'));"`
185185-+ else
186186-+ # distutils.sysconfig way
187187-+ PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
188188-+ print (sysconfig.get_python_lib(0,0));"`
189189-+ fi
190190- fi
191191- AC_MSG_RESULT([$PYTHON_SITE_PKG])
192192- AC_SUBST([PYTHON_SITE_PKG])
193193-194194-+ #
195195-+ # Check for platform-specific site packages
196196-+ #
197197-+ AC_MSG_CHECKING([for Python platform specific site-packages path])
198198-+ if test -z "$PYTHON_SITE_PKG"; then
199199-+ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
200200-+ PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
201201-+ print (sysconfig.get_path('platlib'));"`
202202-+ else
203203-+ # distutils.sysconfig way
204204-+ PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
205205-+ print (sysconfig.get_python_lib(1,0));"`
206206-+ fi
207207-+ fi
208208-+ AC_MSG_RESULT([$PYTHON_PLATFORM_SITE_PKG])
209209-+ AC_SUBST([PYTHON_PLATFORM_SITE_PKG])
210210-+
211211- #
212212- # libraries which must be linked in when embedding
213213- #
214214- AC_MSG_CHECKING(python extra libraries)
215215- if test -z "$PYTHON_EXTRA_LIBS"; then
216216-- PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
217217-- conf = distutils.sysconfig.get_config_var; \
218218-+ PYTHON_EXTRA_LIBS=`$PYTHON -c "$IMPORT_SYSCONFIG; \
219219-+ conf = sysconfig.get_config_var; \
220220- print (conf('LIBS') + ' ' + conf('SYSLIBS'))"`
221221- fi
222222- AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
223223-@@ -278,8 +319,8 @@
224224- #
225225- AC_MSG_CHECKING(python extra linking flags)
226226- if test -z "$PYTHON_EXTRA_LDFLAGS"; then
227227-- PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
228228-- conf = distutils.sysconfig.get_config_var; \
229229-+ PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "$IMPORT_SYSCONFIG; \
230230-+ conf = sysconfig.get_config_var; \
231231- print (conf('LINKFORSHARED'))"`
232232- fi
233233- AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
234234-@@ -291,8 +332,10 @@
235235- AC_MSG_CHECKING([consistency of all components of python development environment])
236236- # save current global flags
237237- ac_save_LIBS="$LIBS"
238238-+ ac_save_LDFLAGS="$LDFLAGS"
239239- ac_save_CPPFLAGS="$CPPFLAGS"
240240-- LIBS="$ac_save_LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS $PYTHON_EXTRA_LIBS"
241241-+ LIBS="$ac_save_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYTHON_EXTRA_LIBS"
242242-+ LDFLAGS="$ac_save_LDFLAGS $PYTHON_EXTRA_LDFLAGS"
243243- CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
244244- AC_LANG_PUSH([C])
245245- AC_LINK_IFELSE([
246246-@@ -303,15 +346,17 @@
247247- # turn back to default flags
248248- CPPFLAGS="$ac_save_CPPFLAGS"
249249- LIBS="$ac_save_LIBS"
250250-+ LDFLAGS="$ac_save_LDFLAGS"
251251-252252- AC_MSG_RESULT([$pythonexists])
253253-254254- if test ! "x$pythonexists" = "xyes"; then
255255-+ # gpgme: only warn here, no error, as we are looking for multiple versions
256256- AC_MSG_WARN([
257257- Could not link test program to Python. Maybe the main Python library has been
258258- installed in some non-standard library path. If so, pass it to configure,
259259-- via the LDFLAGS environment variable.
260260-- Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
261261-+ via the LIBS environment variable.
262262-+ Example: ./configure LIBS="-L/usr/non-standard-path/python/lib"
263263- ============================================================================
264264- You probably have to install the development version of the Python package
265265- for your distribution. The exact name of this package varies among them.
266266-@@ -323,4 +368,4 @@
267267- #
268268- # all done!
269269- #
270270--])
271271-+])
272272-\ No newline at end of file
273273-