Re: Python3 cffi bindings

Subject: Re: Python3 cffi bindings

Date: Fri, 25 Oct 2019 11:57:00 +0200

To: David Bremner, notmuch@notmuchmail.org

Cc:

From: Floris Bruynooghe


On Tue 22 Oct 2019 at 13:32 -0300, David Bremner wrote:

> David Bremner <david@tethera.net> writes:
>
>> 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,
>>
>
> I think I figured it out. Your 'run' function completely overrides the
> environment. But just adding PATH back seems to do the trick. I'm not
> sure if this is the most idomatic change, but it works:
>
> diff --git a/bindings/python-cffi/tests/conftest.py b/bindings/python-cffi/tests/conftest.py
> index 1b7bbc35..6a81aa18 100644
> --- a/bindings/python-cffi/tests/conftest.py
> +++ b/bindings/python-cffi/tests/conftest.py
> @@ -33,9 +33,11 @@ def notmuch(maildir):
>          cfg_fname = maildir.path / 'notmuch-config'
>          cmd = ['notmuch'] + list(args)
>          print('Invoking: {}'.format(' '.join(cmd)))
>                                proc = subprocess.run(cmd,
>                                timeout=5,
> -                              env={'NOTMUCH_CONFIG': str(cfg_fname)})
> +                              env={'PATH':os.environ["PATH"],'NOTMUCH_CONFIG': str(cfg_fname)})
>          proc.check_returncode()
>      return run
>  

This seems reasonable, perhaps even a "env = os.environ.copy();
env['NOTMUCH_CONFIG'] = src(cfg_fname)" is better here so that
LD_LIBRARY_PATH and anything else is kept around.
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: