python-cffi: fix out-of-tree build
authorDavid Bremner <david@tethera.net>
Sun, 31 Oct 2021 10:03:54 +0000 (07:03 -0300)
committerDavid Bremner <david@tethera.net>
Sun, 5 Dec 2021 13:08:48 +0000 (09:08 -0400)
The main idea is to replace the hack of copying version.txt into the
bindings source with a generated _notmuch_config.py file.

This will mean that the bindings only build after configuring and
building notmuch itself. Given those constraints, "pip install ."
should work.

Makefile.local
bindings/python-cffi/notmuch2/_build.py
bindings/python-cffi/setup.py
bindings/python-cffi/version.txt [deleted file]
configure

index e12b94cd6f668bfc830070ec24d924ff8941bebf..10fb99085f54ff9f4f6fef73ae3e41e69dbcf6a4 100644 (file)
@@ -54,7 +54,6 @@ update-versions:
        sed -i -e "s/^__VERSION__[[:blank:]]*=.*$$/__VERSION__ = \'${VERSION}\'/" \
            -e "s/^SOVERSION[[:blank:]]*=.*$$/SOVERSION = \'${LIBNOTMUCH_VERSION_MAJOR}\'/" \
            ${PV_FILE}
-       cp version.txt bindings/python-cffi
 
 # We invoke make recursively only to force ordering of our phony
 # targets in the case of parallel invocation of make (-j).
index f6184b97be773ff8f885b66dc312c1dfeda889f6..45eb20c05ee55707f973b532b555853174e28ea1 100644 (file)
@@ -1,5 +1,5 @@
 import cffi
-
+from _notmuch_config import *
 
 ffibuilder = cffi.FFI()
 ffibuilder.set_source(
@@ -16,8 +16,8 @@ ffibuilder.set_source(
         #ERROR libnotmuch  version < 5.1 not supported
     #endif
     """,
-    include_dirs=['../../lib'],
-    library_dirs=['../../lib'],
+    include_dirs=[NOTMUCH_INCLUDE_DIR],
+    library_dirs=[NOTMUCH_LIB_DIR],
     libraries=['notmuch'],
 )
 ffibuilder.cdef(
index cda5233840bc0e0183181b8464c750ed3dd75866..55fb2d24f832b49e2730db879309b441a58a0a78 100644 (file)
@@ -1,6 +1,7 @@
 import setuptools
+from _notmuch_config import *
 
-with open('version.txt') as fp:
+with open(NOTMUCH_VERSION_FILE) as fp:
     VERSION = fp.read().strip()
 
 setuptools.setup(
diff --git a/bindings/python-cffi/version.txt b/bindings/python-cffi/version.txt
deleted file mode 100644 (file)
index cd46610..0000000
+++ /dev/null
@@ -1 +0,0 @@
-0.34.1
index 6c3a38f1098ace4d563f5962d9470013e898175a..7d9df3708a315ab5bdae7badbc8239d271f412b6 100755 (executable)
--- a/configure
+++ b/configure
@@ -1579,6 +1579,14 @@ EOF
     printf "rsti_dir = '%s'\n" "$(cd emacs && pwd -P)"
 } > sphinx.config
 
+cat > bindings/python-cffi/_notmuch_config.py <<EOF
+# _notmuch_config.py was automatically generated by the configure
+# script in the root of the notmuch source tree.
+NOTMUCH_VERSION_FILE='${NOTMUCH_SRCDIR}/version.txt'
+NOTMUCH_INCLUDE_DIR='${NOTMUCH_SRCDIR}/lib'
+NOTMUCH_LIB_DIR='${NOTMUCH_SRCDIR}/lib'
+EOF
+
 # Finally, after everything configured, inform the user how to continue.
 cat <<EOF