unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Justus Winter <4winter@informatik.uni-hamburg.de>
To: Jed Brown <jed@59A2.org>,  notmuch@notmuchmail.org
Cc: Sebastian Spaeth <Sebastian@SSpaeth.de>
Subject: Re: [RFC/PATCH] python: search parent lib directory for libnotmuch.so
Date: Tue, 09 Apr 2013 16:13:33 +0200	[thread overview]
Message-ID: <20130409141333.7736.41695@thinkbox.jade-hamburg.de> (raw)
In-Reply-To: <1365475646-22926-1-git-send-email-jed@59A2.org>

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                    /home/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0
7f4214357000-7f4214557000 ---p 0001e000 00:17 2120750                    /home/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0
7f4214557000-7f4214559000 rw-p 0001e000 00:17 2120750                    /home/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                    /home/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0
7fa5ecec2000-7fa5ed0c2000 ---p 0001e000 00:17 2120750                    /home/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0
7fa5ed0c2000-7fa5ed0c4000 rw-p 0001e000 00:17 2120750                    /home/teythoon/.local/stow/notmuch/lib/libnotmuch.so.3.0.0
teythoon@thinkbox ~ % env | grep '\.local'
PATH=/home/teythoon/.local/bin:/usr/local/stow/enlightenment/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
LOCAL=/home/teythoon/.local
PYTHONPATH=/home/teythoon/.local/lib/python2.7/site-packages
LD_LIBRARY_PATH=/home/teythoon/.local/lib
PKG_CONFIG_PATH=/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                       /usr/lib/libnotmuch.so.3.0.0
7fd30b457000-7fd30b657000 ---p 0001b000 fe:00 4241                       /usr/lib/libnotmuch.so.3.0.0
7fd30b657000-7fd30b658000 rw-p 0001b000 fe:00 4241                       /usr/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                       /usr/lib/libnotmuch.so.3.0.0
7fadb571f000-7fadb591f000 ---p 0001b000 fe:00 4241                       /usr/lib/libnotmuch.so.3.0.0
7fadb591f000-7fadb5920000 rw-p 0001b000 fe:00 4241                       /usr/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

  reply	other threads:[~2013-04-09 14:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-09  2:47 [RFC/PATCH] python: search parent lib directory for libnotmuch.so Jed Brown
2013-04-09 14:13 ` Justus Winter [this message]
2013-04-09 14:57   ` Jed Brown
2013-04-09 15:21     ` Justus Winter
2013-04-09 15:31       ` Jed Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130409141333.7736.41695@thinkbox.jade-hamburg.de \
    --to=4winter@informatik.uni-hamburg.de \
    --cc=Sebastian@SSpaeth.de \
    --cc=jed@59A2.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).