python-cffi: fix out-of-tree build

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.
This commit is contained in:
David Bremner 2021-10-31 07:03:54 -03:00
parent 95f0c59fe9
commit f17d75b83c
5 changed files with 13 additions and 6 deletions

View 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).

View 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(

View 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(

View file

@ -1 +0,0 @@
0.34.1

8
configure vendored
View file

@ -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