Re: Python3 cffi bindings

Subject: Re: Python3 cffi bindings

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

To: Floris Bruynooghe, notmuch@notmuchmail.org

Cc:

From: David Bremner


Floris Bruynooghe <flub@devork.be> 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/_build.py  # creates notdb/_capi.cpython-37m-x86_64-linux-gnu.so
> $ popd
> $ pushd test
> $ ./T391-pytest.sh

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

1) using "python3 setup.py --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/conftest.py b/bindings/python-cffi/tests/conftest.py
index 1b7bbc35..ac17397c 100644
--- a/bindings/python-cffi/tests/conftest.py
+++ b/bindings/python-cffi/tests/conftest.py
@@ -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 = subprocess.run(cmd,

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

test.output.xz (application/x-xz)
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: