configure: use cffi.FFI().verify() to test buildability of CFFI bindings
authorTomi Ollila <tomi.ollila@iki.fi>
Tue, 9 Jun 2020 12:32:27 +0000 (15:32 +0300)
committerDavid Bremner <david@tethera.net>
Wed, 10 Jun 2020 02:06:03 +0000 (23:06 -0300)
Checking existence of pyconfig.h to determine whether CFFI-based
notmuch bindings are buildable is not enough; for example Fedora 32
ships pyconfig.h in python3-libs package, but python3-devel is required
to be installed for the bindings to build.

Executing cffi.FFI().verify() is pretty close to what is done in
bindings/python-cffi/notmuch2/_build.py to get the c code part of the
bindings built.

configure

index f4b3c61afb95521a22acec5eb410edaa03e2ba67..05ade05b5adaa9cfaa9023afec5e4c8e2da50de5 100755 (executable)
--- a/configure
+++ b/configure
@@ -711,14 +711,12 @@ if [ $have_python -eq 0 ]; then
     errors=$((errors + 1))
 fi
 
-have_python3_dev=0
+have_python3=0
 if [ $have_python -eq 1 ]; then
-    printf "Checking for python3 dev (>= 3.5)..."
-    if "$python" -c 'import os, sys, sysconfig;
-assert sys.version_info >= (3,5)
-assert os.path.isfile(sysconfig.get_config_h_filename())' >/dev/null 2>&1; then
+    printf "Checking for python3 (>= 3.5)..."
+    if "$python" -c 'import sys, sysconfig; assert sys.version_info >= (3,5)'; >/dev/null 2>&1; then
         printf "Yes.\n"
-        have_python3_dev=1
+        have_python3=1
     else
         printf "No (will not install CFFI-based python bindings).\n"
     fi
@@ -726,14 +724,15 @@ fi
 
 have_python3_cffi=0
 have_python3_pytest=0
-if [ $have_python3_dev -eq 1 ]; then
+if [ $have_python3 -eq 1 ]; then
     printf "Checking for python3 cffi and setuptools... "
-    if "$python" -c 'import cffi; import setuptools' >/dev/null 2>&1; then
+    if "$python" -c 'import cffi,setuptools; cffi.FFI().verify()' >/dev/null 2>&1; then
         printf "Yes.\n"
         have_python3_cffi=1
     else
         printf "No (will not install CFFI-based python bindings).\n"
     fi
+    rm -rf __pycache__  # cffi.FFI().verify() uses this space
 
     printf "Checking for python3 pytest (>= 3.0)... "
     conf=$(mktemp)