From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MEaHEVeMLWCFUAAA0tVLHw (envelope-from ) for ; Wed, 17 Feb 2021 21:36:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id sEItDVeMLWDobQAA1q6Kng (envelope-from ) for ; Wed, 17 Feb 2021 21:36:23 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7349E24916 for ; Wed, 17 Feb 2021 22:36:22 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id AD3F81FD75; Wed, 17 Feb 2021 16:36:13 -0500 (EST) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) by mail.notmuchmail.org (Postfix) with ESMTPS id 4023E1FBB5 for ; Wed, 17 Feb 2021 16:36:11 -0500 (EST) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 231171B00046; Wed, 17 Feb 2021 23:36:05 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1613597765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=oUxcbK/Z9NaG789YeAgEVi+MUDS15/Ez5GMKaaoMZiw=; b=cwrUjcsGb0BIGnCNfwEYanRyLgTwwFk/HJqerFGSkBFoL3Fs9nqe6Ffq8C0RwzVCm90ib7 k7xjVKSFwkhDIoXarO71ecAgOGn2hc+bdhZSSE6HkmuAKTBjHEdoqv3IkLFVGQwnn51alo LZoyJwehZN0dCYjcEexdtMY1xbooI7L9c9X4WAhLYIPRUlEDT4zEEhhYYtN5tyEBCb9nzX LWJnuPVfi7rlpCsPdbthSTuB8s6ei0X/3GRAbf8YbZbn2fdr0PUvqBXuf7B0r9l21cERM0 4Ig4vtXLfz0rNJ0U73Qy33nUXTsG/FBplBlzC46wBUksqaQIaX+XKI9z3D/L6A== From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [RFC PATCH] python-cffi out-of-tree build Date: Wed, 17 Feb 2021 23:36:00 +0200 Message-Id: <20210217213600.10268-1-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1613597765; a=rsa-sha256; cv=none; b=etcFPsCUrj+Asc1BQOofw18e47h9vSd1d/vhZO2owbonKVW05jmpF9pwnTZC/cE3+y/Q55 P0zuTUtvwWnl9HrzFOC+G+MGyLDKDMvt3FMyxziSRckKS2+nd8tqLDd1uOwOTkvJQi1LzM /SeTsrp9OPpoZJlGnfboGn4Lf9/2Xc4enT2sRGafx6xk/xJdAUlOZM535VEyKCyg4gqlrf 6wUU0PcDPs4Gkc3ImWF7HeuI5QlWItlWWpQRBdtqhODikV4J8X6gKu5l6yV4VFWJ0asYEX k/S3NhrgpAGuy6FYx0KXhqoFqvH+UbYJByhjWiEuJEWYipS+YXcuNYDmrVqZxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1613597765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=oUxcbK/Z9NaG789YeAgEVi+MUDS15/Ez5GMKaaoMZiw=; b=WO+Nhh9yGSE2q6hiP3uynUaLnBSiYNb8BfkkDqcmUMRjehcwiovHKceep3FC3RJQLEGCL9 oBTEjPnXQRxKzfkZXWQuFbenJBdte7CfXXEklbLbkcIRqOXwPGj2LrHPk1HlDRejezAt8U IiP6nkHGTfV7TcC6zfGn4gvgkyMmqPp7nhn0HrUZGUi8BPOTtCAvfqo7/tirw8DT+rdHXo Nt98/At8LVP8MextZZvni4nICC1Lzl+ZpLOwaPGbTOvEqptB0J86Tkmb05WcclW34YQ6zp QUtx6K3DOyz+akQop2svdr5BcMb2/pMg+JPycG+97g2q1STYTmAs2+mQH13Geg== Message-ID-Hash: DPOBHMOGSNNLEWLZ44AHPXU5T2D2H46W X-Message-ID-Hash: DPOBHMOGSNNLEWLZ44AHPXU5T2D2H46W X-MailFrom: tomi.ollila@iki.fi X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: tomi.ollila@iki.fi X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 3.56 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=cwrUjcsG; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 7349E24916 X-Spam-Score: 3.56 X-Migadu-Scanner: scn0.migadu.com X-TUID: iYmJFJKwWKrw 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