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. --- an RFC alternative to id:20210215215410.28668-1-tomi.ollila@iki.fi I really don't know how this should be done... do they even in e.g. https://github.com/pypa/pip/issues/7555 ? Tested to work in in-tree build, and out-of-tree builds referencing .../notmuch/configure with absolute and relative paths, and all 3 builds worked. When doing out-of-tree build, only _capi.abi3.so appeared in bindings/python-cffi/build/stage/notmuch2/ -- in case of in-tree build all the notmuch2/*.py source files also got copied there... ... I tried this changei in setup.py: . - packages=setuptools.find_packages(exclude=['tests']) . + packages=setuptools.find_packages(dn0, exclude=['tests']) but then build broke. bindings/Makefile.local | 5 +++-- bindings/python-cffi/notmuch2/_build.py | 6 +++++- bindings/python-cffi/setup.py | 9 +++++++-- bindings/python-cffi/version.txt | 1 - configure | 4 ---- 5 files changed, 15 insertions(+), 10 deletions(-) delete mode 100644 bindings/python-cffi/version.txt diff --git a/bindings/Makefile.local b/bindings/Makefile.local index bc960bbc..d5c70bff 100644 --- a/bindings/Makefile.local +++ b/bindings/Makefile.local @@ -15,9 +15,10 @@ endif python-cffi-bindings: lib/$(LINKER_NAME) ifeq ($(HAVE_PYTHON3_CFFI),1) + test '$(srcdir)' = . && bdir=. || bdir='$(NOTMUCH_SRCDIR)/$(dir)/python-cffi'; \ cd $(dir)/python-cffi && \ - ${PYTHON} setup.py build --build-lib build/stage && \ - mkdir -p build/stage/tests && cp tests/*.py build/stage/tests + ${PYTHON} "$$bdir"/setup.py build --build-lib build/stage && \ + mkdir -p build/stage/tests && cp "$$bdir"/tests/*.py build/stage/tests endif CLEAN += $(patsubst %,$(dir)/ruby/%, \ diff --git a/bindings/python-cffi/notmuch2/_build.py b/bindings/python-cffi/notmuch2/_build.py index f67b4de6..ad585d21 100644 --- a/bindings/python-cffi/notmuch2/_build.py +++ b/bindings/python-cffi/notmuch2/_build.py @@ -1,5 +1,9 @@ import cffi +import os +import sys + +dn0 = os.path.dirname(sys.argv[0]) ffibuilder = cffi.FFI() ffibuilder.set_source( @@ -16,7 +20,7 @@ ffibuilder.set_source( #ERROR libnotmuch version < 5.1 not supported #endif """, - include_dirs=['../../lib'], + include_dirs=[dn0 + '/../../lib'], library_dirs=['../../lib'], libraries=['notmuch'], ) diff --git a/bindings/python-cffi/setup.py b/bindings/python-cffi/setup.py index cda52338..5884944b 100644 --- a/bindings/python-cffi/setup.py +++ b/bindings/python-cffi/setup.py @@ -1,6 +1,11 @@ import setuptools -with open('version.txt') as fp: +import os +import sys + +dn0 = os.path.dirname(sys.argv[0]) + +with open(dn0 + '/../../version.txt') as fp: VERSION = fp.read().strip() setuptools.setup( @@ -12,7 +17,7 @@ setuptools.setup( setup_requires=['cffi>=1.0.0'], install_requires=['cffi>=1.0.0'], packages=setuptools.find_packages(exclude=['tests']), - cffi_modules=['notmuch2/_build.py:ffibuilder'], + cffi_modules=[dn0 + '/notmuch2/_build.py:ffibuilder'], classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', diff --git a/bindings/python-cffi/version.txt b/bindings/python-cffi/version.txt deleted file mode 100644 index 8239f42d..00000000 --- a/bindings/python-cffi/version.txt +++ /dev/null @@ -1 +0,0 @@ -0.31.3 diff --git a/configure b/configure index cfa9c09b..7bdd7a13 100755 --- a/configure +++ b/configure @@ -74,10 +74,6 @@ if [ "$srcdir" != "." ]; then # Use the same hack to replicate python-cffi source for # out-of-tree builds (again, not ideal). mkdir bindings/python-cffi - cp -a "$srcdir"/bindings/python-cffi/tests \ - "$srcdir"/bindings/python-cffi/notmuch2 \ - "$srcdir"/bindings/python-cffi/setup.py \ - bindings/python-cffi/ fi # Set several defaults (optionally specified by the user in -- 2.29.2 _______________________________________________ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-leave@notmuchmail.org