Re: [PATCH 4/4] python-cffi: switch to notmuch_database_{open,create}_with_config
On Sat, Oct 30 2021, David Bremner wrote: > Since release 0.32, libnotmuch provides searching for database and > configuration paths. This commit changes the python module notmuch2 to > use those facilities. > > This fixes the bug reported in [1], along with a couple of the > deprecation warnings in the python bindings. > > Database.default_path is deprecated, since it no longer faithfully > reflects what libnotmuch is doing, and it is also no longer used in > the bindings themselves. > > This commit choose the default of config=CONFIG.EMPTY (equivalent to > passing "" to notmuch_database_open_with_config). This makes the > change upward compatible API-wise (at least as far as the test suite > verifies), but changing the default to CONFIG.SEARCH would probably be > more convenient for bindings users. Generally this series looks good to me -- some suspicious newlines I see, some (if not all) of those might be ok... > > [1]: id:87h7d4wp6b@tethera.net > --- > bindings/python-cffi/notmuch2/_build.py| 26 --- > bindings/python-cffi/notmuch2/_database.py | 81 -- > doc/man1/notmuch-config.rst| 2 + > test/T055-path-config.sh | 5 +- > test/T391-python-cffi.sh | 8 ++- > 5 files changed, 82 insertions(+), 40 deletions(-) > > diff --git a/bindings/python-cffi/notmuch2/_build.py > b/bindings/python-cffi/notmuch2/_build.py > index 24df939e..f6184b97 100644 > --- a/bindings/python-cffi/notmuch2/_build.py > +++ b/bindings/python-cffi/notmuch2/_build.py > @@ -103,20 +103,18 @@ ffibuilder.cdef( > notmuch_status_to_string (notmuch_status_t status); > > notmuch_status_t > -notmuch_database_create_verbose (const char *path, > - notmuch_database_t **database, > - char **error_message); > -notmuch_status_t > -notmuch_database_create (const char *path, notmuch_database_t > **database); > -notmuch_status_t > -notmuch_database_open_verbose (const char *path, > - notmuch_database_mode_t mode, > - notmuch_database_t **database, > - char **error_message); > -notmuch_status_t > -notmuch_database_open (const char *path, > - notmuch_database_mode_t mode, > - notmuch_database_t **database); > +notmuch_database_create_with_config (const char *database_path, > + const char *config_path, > + const char *profile, > + notmuch_database_t **database, > + char **error_message); > +notmuch_status_t > +notmuch_database_open_with_config (const char *database_path, > + notmuch_database_mode_t mode, > + const char *config_path, > + const char *profile, > + notmuch_database_t **database, > + char **error_message); > notmuch_status_t > notmuch_database_close (notmuch_database_t *database); > notmuch_status_t > diff --git a/bindings/python-cffi/notmuch2/_database.py > b/bindings/python-cffi/notmuch2/_database.py > index c1fb88eb..92bfdef2 100644 > --- a/bindings/python-cffi/notmuch2/_database.py > +++ b/bindings/python-cffi/notmuch2/_database.py > @@ -31,6 +31,9 @@ class Mode(enum.Enum): > READ_ONLY = capi.lib.NOTMUCH_DATABASE_MODE_READ_ONLY > READ_WRITE = capi.lib.NOTMUCH_DATABASE_MODE_READ_WRITE > > +class ConfigFile(enum.Enum): > +EMPTY = b'' > +SEARCH = capi.ffi.NULL > > class QuerySortOrder(enum.Enum): > OLDEST_FIRST = capi.lib.NOTMUCH_SORT_OLDEST_FIRST > @@ -71,6 +74,9 @@ class Database(base.NotmuchObject): > :cvar EXCLUDE: Which messages to exclude from queries, ``TRUE``, > ``FLAG``, ``FALSE`` or ``ALL``. See the query documentation > for details. > +:cvar CONFIG: Control loading of config file. Enumeration of > + ``EMPTY`` (don't load a config file), and ``SEARCH`` (search as > + in :ref:`config_search`) > :cvar AddedMessage: A namedtuple ``(msg, dup)`` used by > :meth:`add` as return value. > :cvar STR_MODE_MAP: A map mapping strings to :attr:`MODE` items. > @@ -81,9 +87,8 @@ class Database(base.NotmuchObject): > still open. > > :param path: The directory of where the database is stored. If > - ``None`` the location will be read from the user's > - configuration file, respecting the ``NOTMUCH_CONFIG`` > - environment variable if set. > + ``None`` the location will be searched according to > + :ref:`database` > :type path: str, bytes, os.PathLike or pathlib.Path > :param mode: The
Re: [PATCH] emacs: don't add space to tag completion candidates.
On Sat, Oct 30 2021, David Bremner wrote: > "inwit" writes: > >> Works as expected under selectrum! Thanks! >> >> > > right, I guess the question is how annoying it is for users of standard > emacs completion. I generally enter one tag at a time, so it won't > really affect me. I recall doing adding many tags, but very seldom. I'd guess the need to press space before entering next is tolerable (basing my guess on my experiences w/ various experiences w/ filename completion...) > > d Tomi ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [RFC PATCH] python-cffi out-of-tree build
On Sun, Oct 31 2021, David Bremner wrote: > Tomi Ollila writes: > >> setup.py and _build.py to refer some other files based on directory >> where setup.py is located (os.path.dirname(sys.argv[0]). >> >> Dropped bindings/python-cffi/version.txt and refer ../../version.txt >> instead -- _build.py already refers ../../lib so why have version.txt >> twice (with identical content). >> >> Dropped copying of bindings/python-cffi source files to the build >> directory bindings/python-cffi in configure. > > Apologies, I think I did not read this discussion very carefully > before. I guess [1] is an alternative to the first two points. I'm not > sure which approach is better. Mine is a bigger hammer, but maybe that > could be useful in the future? > > The patch at [1] does not (by itself) allow the third change, but > probably some similar hacking of setup.py, but using the newly created > _notmuch_config.py would work. > > Tomi, did you happen to test "pip install ." with your approach? I'm > afraid your patch doesn't (easily) apply anymore so I was too lazy to > test myself. IIRC my approaches had quite a few problems which I thought soon after emailing so probablhy your versions are better. Have to look... Tomi > > Cheers, > > db > > [1]: id:20211031100354.1697379-1-da...@tethera.net > ___ > notmuch mailing list -- notmuch@notmuchmail.org > To unsubscribe send an email to notmuch-le...@notmuchmail.org ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [RFC PATCH] python-cffi out-of-tree build
Tomi Ollila writes: > setup.py and _build.py to refer some other files based on directory > where setup.py is located (os.path.dirname(sys.argv[0]). > > Dropped bindings/python-cffi/version.txt and refer ../../version.txt > instead -- _build.py already refers ../../lib so why have version.txt > twice (with identical content). > > Dropped copying of bindings/python-cffi source files to the build > directory bindings/python-cffi in configure. Apologies, I think I did not read this discussion very carefully before. I guess [1] is an alternative to the first two points. I'm not sure which approach is better. Mine is a bigger hammer, but maybe that could be useful in the future? The patch at [1] does not (by itself) allow the third change, but probably some similar hacking of setup.py, but using the newly created _notmuch_config.py would work. Tomi, did you happen to test "pip install ." with your approach? I'm afraid your patch doesn't (easily) apply anymore so I was too lazy to test myself. Cheers, db [1]: id:20211031100354.1697379-1-da...@tethera.net ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH] 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. --- 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.. --- 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 <