From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 9 Apr 2013 14:13:33 +0000 (+0200) Subject: Re: [RFC/PATCH] python: search parent lib directory for libnotmuch.so X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e5d4679b2174d12ced0dde97c8140f2eb647d407;p=notmuch-archives.git Re: [RFC/PATCH] python: search parent lib directory for libnotmuch.so --- diff --git a/21/0f7f6279761d795214462cb4ba1836443c5acf b/21/0f7f6279761d795214462cb4ba1836443c5acf new file mode 100644 index 000000000..2c52299bf --- /dev/null +++ b/21/0f7f6279761d795214462cb4ba1836443c5acf @@ -0,0 +1,148 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 11534431FBC + for ; Tue, 9 Apr 2013 07:13:43 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id amDuD0dZCYXf for ; + Tue, 9 Apr 2013 07:13:42 -0700 (PDT) +Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68]) + (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 1F669431FAE + for ; Tue, 9 Apr 2013 07:13:42 -0700 (PDT) +Received: from mail.jade-hamburg.de (mail.jade-hamburg.de [85.183.11.228]) + (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.cryptobitch.de (Postfix) with ESMTPSA id A3A0F601883 + for ; Tue, 9 Apr 2013 16:13:39 +0200 (CEST) +Received: by mail.jade-hamburg.de (Postfix, from userid 401) + id 13276DF2A3; Tue, 9 Apr 2013 16:13:38 +0200 (CEST) +Received: from thinkbox.jade-hamburg.de (cryptobitch.de [88.198.7.68]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) (Authenticated sender: teythoon) + by mail.jade-hamburg.de (Postfix) with ESMTPSA id 74A42DF28B; + Tue, 9 Apr 2013 16:13:35 +0200 (CEST) +Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.80) + (envelope-from ) + id 1UPZIk-0004Jv-43; Tue, 09 Apr 2013 16:13:34 +0200 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +To: Jed Brown , notmuch@notmuchmail.org +From: Justus Winter <4winter@informatik.uni-hamburg.de> +In-Reply-To: <1365475646-22926-1-git-send-email-jed@59A2.org> +References: <1365475646-22926-1-git-send-email-jed@59A2.org> +Message-ID: <20130409141333.7736.41695@thinkbox.jade-hamburg.de> +User-Agent: alot/0.3.3+ +Subject: Re: [RFC/PATCH] python: search parent lib directory for libnotmuch.so +Date: Tue, 09 Apr 2013 16:13:33 +0200 +Cc: Sebastian Spaeth +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 09 Apr 2013 14:13:43 -0000 + +Hi Jed, + +Quoting Jed Brown (2013-04-09 04:47:26) +> If libnotmuch.so is installed to a path that is not searched by +> dlopen(3), we must import it using an absolute path because the Python +> bindings do not have the luxury of RPATH linking. So strip off the +> trailing directories from the install location and try CDLL with an +> absolute path. + +May I ask why you cannot use LD_LIBRARY_PATH? I too install libnotmuch +to a non-standard location as unprivileged user and to make this +library available I add its path to LD_LIBRARY_PATH. It seems to work +just fine: + +teythoon@thinkbox ~ % python -c 'import notmuch; print("\n".join(l.strip() = +for l in open("/proc/self/maps") if "notmuch" in l))' +7f4214339000-7f4214357000 r-xp 00000000 00:17 2120750 /h= +ome/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0 +7f4214357000-7f4214557000 ---p 0001e000 00:17 2120750 /h= +ome/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0 +7f4214557000-7f4214559000 rw-p 0001e000 00:17 2120750 /h= +ome/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0 +teythoon@thinkbox ~ % python3.2 -c 'import notmuch; print("\n".join(l.strip= +() for l in open("/proc/self/maps") if "notmuch" in l))' +7fa5ecea4000-7fa5ecec2000 r-xp 00000000 00:17 2120750 /h= +ome/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0 +7fa5ecec2000-7fa5ed0c2000 ---p 0001e000 00:17 2120750 /h= +ome/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0 +7fa5ed0c2000-7fa5ed0c4000 rw-p 0001e000 00:17 2120750 /h= +ome/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0 +teythoon@thinkbox ~ % env | grep '\.local' +PATH=3D/home/teythoon/.local/bin:/usr/local/stow/enlightenment/bin:/usr/loc= +al/bin:/usr/bin:/bin:/usr/games +LOCAL=3D/home/teythoon/.local +PYTHONPATH=3D/home/teythoon/.local/lib/python2.7/site-packages +LD_LIBRARY_PATH=3D/home/teythoon/.local/lib +PKG_CONFIG_PATH=3D/home/teythoon/.local/lib/pkgconfig +teythoon@thinkbox ~ % unset LD_LIBRARY_PATH +teythoon@thinkbox ~ % python -c 'import notmuch; print("\n".join(l.strip() = +for l in open("/proc/self/maps") if "notmuch" in l))' +7fd30b43c000-7fd30b457000 r-xp 00000000 fe:00 4241 /u= +sr/lib/libnotmuch.so.3.0.0 +7fd30b457000-7fd30b657000 ---p 0001b000 fe:00 4241 /u= +sr/lib/libnotmuch.so.3.0.0 +7fd30b657000-7fd30b658000 rw-p 0001b000 fe:00 4241 /u= +sr/lib/libnotmuch.so.3.0.0 +teythoon@thinkbox ~ % python3.2 -c 'import notmuch; print("\n".join(l.strip= +() for l in open("/proc/self/maps") if "notmuch" in l))' +7fadb5704000-7fadb571f000 r-xp 00000000 fe:00 4241 /u= +sr/lib/libnotmuch.so.3.0.0 +7fadb571f000-7fadb591f000 ---p 0001b000 fe:00 4241 /u= +sr/lib/libnotmuch.so.3.0.0 +7fadb591f000-7fadb5920000 rw-p 0001b000 fe:00 4241 /u= +sr/lib/libnotmuch.so.3.0.0 + +> --- +> This is sort of a hack, but I don't know a less intrusive way to get +> libnotmuch.so from somewhere dlopen(3) doesn't already search. +> = + +> The absolute path version won't do the right thing in case of 'setup.py +> develop', otherwise we could use it in all cases. It may still make +> sense to make the absolute path version take precedence. + +Well, if something like this is necessary and wanted (opinions +anyone?) at least let's not hardcode the assumption about the +directory layout but just walk up the tree until we find notmuch.so.3 +or lib/notmuch.so.3. This way the bindings will find the correct +library even when they are included directly from within the source +tree. + +Otoh, adding such behavior might be 'surprising' and lead to many +problems down the road like spurious bug reports just because the +magic library finder locates a rogue libnotmuch.so.3 somewhere. + +> An alternative would be to find libnotmuch.so using the notmuch +> executable. + +How would you do that? fork'ing and exec'ing is not an option (and I'm +not sure what one could achieve by exec'ing it, but how else would you +talk to the dynamic linker?) , and poking around in binaries to get +their rpath isn't either in my opinion. And you would have to locate +the 'right' binary in the first place? + +Cheers, +Justus