Re: Python3 cffi bindings

Subject: Re: Python3 cffi bindings

Date: Sun, 20 Oct 2019 09:22:38 -0300

To: Floris Bruynooghe,


From: David Bremner

Floris Bruynooghe <> writes:
> It is possible to run this without installing, but it does need a build
> step since cffi (in the mode used - which is the recommended mode) needs
> to build an extension module.  I did something like this, using my
> debian testing system-installed python
> $ export PYTHONPATH=$(pwd)/bindings/python-cffi
> $ pushd bindings/python-cffi
> $ python3 notdb/  # creates notdb/
> $ popd
> $ pushd test
> $ ./

Yes, I think I arrived at a similar place, except

1) using "python3 --build-lib build/stage" to build. I'm not
sure which is better, I think it will depend a bit on when we try to get
out of tree builds working. It is a bit nicer to have the build output
out of tree, but then I have to copy the tests.

2) instead of changing PYTHONPATH, use "python3 -m pytest", which picks
up the module in the current directory. 

> Does that more or less work?  One problem with this is that it will pick
> up the system-wide installed notmuch though.  I guess the way to change
> this is by tweaking CFLAGS=-I... LDFLAGS=-L... or so when building?  But
> than you also have the whole RPATH/LD_LIBRARY_PATH stuff going on as
> well.  Does notmuch abstract any of this away already for it's test
> suite?

The LD_LIBRARY_PATH is already set by the test harness, as is PATH (to
find notmuch). It looks like your function notmuch is not respecting
PATH (see attached log). if I hack something like

diff --git a/bindings/python-cffi/tests/ b/bindings/python-cffi/tests/
index 1b7bbc35..ac17397c 100644
--- a/bindings/python-cffi/tests/
+++ b/bindings/python-cffi/tests/
@@ -31,7 +31,7 @@ def notmuch(maildir):
         accidentally do this in the unittests.
         cfg_fname = maildir.path / 'notmuch-config'
-        cmd = ['notmuch'] + list(args)
+        cmd = ['../../notmuch'] + list(args)
         print('Invoking: {}'.format(' '.join(cmd)))
         proc =,

then the tests pass, but this is obviously not a good solution.

test.output.xz (application/x-xz)
notmuch mailing list