unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH] python-cffi: fix out-of-tree build
Date: Sun, 31 Oct 2021 07:03:54 -0300	[thread overview]
Message-ID: <20211031100354.1697379-1-david@tethera.net> (raw)

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                          | 1 -
 bindings/python-cffi/notmuch2/_build.py | 6 +++---
 bindings/python-cffi/setup.py           | 3 ++-
 bindings/python-cffi/version.txt        | 1 -
 configure                               | 9 +++++++++
 5 files changed, 14 insertions(+), 6 deletions(-)
 delete mode 100644 bindings/python-cffi/version.txt

diff --git a/Makefile.local b/Makefile.local
index e12b94cd..10fb9908 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -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).
diff --git a/bindings/python-cffi/notmuch2/_build.py b/bindings/python-cffi/notmuch2/_build.py
index 24df939e..ef40020b 100644
--- a/bindings/python-cffi/notmuch2/_build.py
+++ b/bindings/python-cffi/notmuch2/_build.py
@@ -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(
diff --git a/bindings/python-cffi/setup.py b/bindings/python-cffi/setup.py
index cda52338..55fb2d24 100644
--- a/bindings/python-cffi/setup.py
+++ b/bindings/python-cffi/setup.py
@@ -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
index 61d2f357..00000000
--- a/bindings/python-cffi/version.txt
+++ /dev/null
@@ -1 +0,0 @@
-0.34
diff --git a/configure b/configure
index 6c3a38f1..69173648 100755
--- a/configure
+++ b/configure
@@ -1579,6 +1579,15 @@ EOF
     printf "rsti_dir = '%s'\n" "$(cd emacs && pwd -P)"
 } > sphinx.config
 
+# construct notmuch_build.py
+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
 
-- 
2.33.0

             reply	other threads:[~2021-10-31 10:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-31 10:03 David Bremner [this message]
2021-12-05 13:25 ` [PATCH] python-cffi: fix out-of-tree build David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211031100354.1697379-1-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).