--- /dev/null
+Return-Path: <five9a2@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id E24E4431FBD\r
+ for <notmuch@notmuchmail.org>; Mon, 8 Apr 2013 19:47:40 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.301\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.301 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, \r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 83Ec+Jbs1uHU for <notmuch@notmuchmail.org>;\r
+ Mon, 8 Apr 2013 19:47:40 -0700 (PDT)\r
+Received: from mail-ia0-f170.google.com (mail-ia0-f170.google.com\r
+ [209.85.210.170]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 7248D431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 8 Apr 2013 19:47:40 -0700 (PDT)\r
+Received: by mail-ia0-f170.google.com with SMTP id j38so1766179iad.15\r
+ for <notmuch@notmuchmail.org>; Mon, 08 Apr 2013 19:47:40 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer;\r
+ bh=UtFDCnMFevgPzeNOUyxqHIH0HphVeKAJc/iPtEv3ONY=;\r
+ b=kh6rQUo5SkQD1rjsgEq6swwk/teWoxh5/rpAqXKxA3dqsd+Ghh/pQqbb08l61CmZoe\r
+ WpM8eCjli4jFp1LPyQ7Pp0zv50BDXKih5dxQHTNGC9NpgcK+SF9i2ZfP0/6cX+2W5f2y\r
+ pvXB2kuApNN5QfF7TSi4RYcNWixNnbUyVgmu3kocnDv4GYV9PqHruKebtlja7gujTMPo\r
+ zOoRd7eQ/U/7ZqvLvEuTdB/b6MSi03QPWyNNuERf9XQquX+XxQkcotPtASHVhINcDeNX\r
+ W8NVLSfZbwhDHkxpjuWC8hVBOXuaVZ7iU8D4xOtIgCSwCMtQd9i2f1h4n6KTz6Fjf7VP\r
+ pdpA==\r
+X-Received: by 10.50.73.65 with SMTP id j1mr9454186igv.49.1365475658964;\r
+ Mon, 08 Apr 2013 19:47:38 -0700 (PDT)\r
+Received: from localhost ([38.69.41.96])\r
+ by mx.google.com with ESMTPS id in10sm24945694igc.1.2013.04.08.19.47.37\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Mon, 08 Apr 2013 19:47:38 -0700 (PDT)\r
+Sender: Jed Brown <five9a2@gmail.com>\r
+From: Jed Brown <jed@59A2.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC/PATCH] python: search parent lib directory for libnotmuch.so\r
+Date: Mon, 8 Apr 2013 21:47:26 -0500\r
+Message-Id: <1365475646-22926-1-git-send-email-jed@59A2.org>\r
+X-Mailer: git-send-email 1.8.2.1\r
+Cc: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 09 Apr 2013 02:47:41 -0000\r
+\r
+If libnotmuch.so is installed to a path that is not searched by\r
+dlopen(3), we must import it using an absolute path because the Python\r
+bindings do not have the luxury of RPATH linking. So strip off the\r
+trailing directories from the install location and try CDLL with an\r
+absolute path.\r
+---\r
+This is sort of a hack, but I don't know a less intrusive way to get\r
+libnotmuch.so from somewhere dlopen(3) doesn't already search.\r
+\r
+The absolute path version won't do the right thing in case of 'setup.py\r
+develop', otherwise we could use it in all cases. It may still make\r
+sense to make the absolute path version take precedence.\r
+\r
+An alternative would be to find libnotmuch.so using the notmuch\r
+executable.\r
+\r
+ bindings/python/notmuch/globals.py | 19 ++++++++++++++++++-\r
+ 1 file changed, 18 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py\r
+index c7632c3..2473f04 100644\r
+--- a/bindings/python/notmuch/globals.py\r
++++ b/bindings/python/notmuch/globals.py\r
+@@ -24,7 +24,24 @@ from ctypes import CDLL, Structure, POINTER\r
+ try:\r
+ nmlib = CDLL("libnotmuch.so.3")\r
+ except:\r
+- raise ImportError("Could not find shared 'notmuch' library.")\r
++ try:\r
++ # If Notmuch is installed to a location not searched by\r
++ # dlopen(3), we must import it using an absolute path. We\r
++ # can't just reset LD_LIBRARY_PATH because ld.so reads it when\r
++ # Python is starting and will not reread the environment. We\r
++ # assume the install directory structure has the form:\r
++ #\r
++ # /base-path/lib/pythonX.Y/site-packages/notmuch/globals.py\r
++ #\r
++ # so that we can get the library directory by stripping off\r
++ # the last four elements of the path.\r
++ import os.path\r
++ path = os.path.abspath(__file__)\r
++ for i in range(4):\r
++ path = os.path.dirname(path)\r
++ nmlib = CDLL(os.path.join(path, 'libnotmuch.so.3'))\r
++ except:\r
++ raise ImportError("Could not find shared 'notmuch' library.")\r
+ \r
+ from .compat import Python3StringMixIn, encode_utf8 as _str\r
+ \r
+-- \r
+1.8.2.1\r
+\r