···4040 url = "https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20200415/f7be62d1/attachment.obj";
4141 sha256 = "00d4sxq63601lzdp2ha1i8fvybh7dzih4531jh8bx07fab3sw65g";
4242 })
4343- # Support for Python 3.10, https://dev.gnupg.org/D545
4444- ./support-python-310.patch
4343+ # Support Python 3.10 version detection without distutils, https://dev.gnupg.org/D545
4444+ ./python-310-detection-without-distutils.patch
4545+ # Find correct version string for Python >= 3.10, https://dev.gnupg.org/D546
4646+ ./python-find-version-string-above-310.patch
4547 # Disable python tests on Darwin as they use gpg (see configureFlags below)
4648 ] ++ lib.optional stdenv.isDarwin ./disable-python-tests.patch
4749 # Fix _AC_UNDECLARED_WARNING for autoconf>=2.70
···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+