[PATCH] NEWS, python: add --libnotmuch-dir option to "setup.py install"
authorDaniel Lee Harple <dlh@harple.com>
Tue, 28 Jun 2016 04:04:21 +0000 (00:04 +2000)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:08 +0000 (16:22 -0700)
92/84ba1d6e03c0dd561e9eebd12a33bb5f9eaa75 [new file with mode: 0644]

diff --git a/92/84ba1d6e03c0dd561e9eebd12a33bb5f9eaa75 b/92/84ba1d6e03c0dd561e9eebd12a33bb5f9eaa75
new file mode 100644 (file)
index 0000000..13ef83c
--- /dev/null
@@ -0,0 +1,186 @@
+Return-Path: <lee@harple.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 arlo.cworth.org (Postfix) with ESMTP id AC3786DE014D\r
+ for <notmuch@notmuchmail.org>; Mon, 27 Jun 2016 21:04:32 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.911\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.911 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H2=-0.211] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id D3GZcNzcTrjB for <notmuch@notmuchmail.org>;\r
+ Mon, 27 Jun 2016 21:04:23 -0700 (PDT)\r
+Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com\r
+ [209.85.192.174])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id E07CA6DE00CC\r
+ for <notmuch@notmuchmail.org>; Mon, 27 Jun 2016 21:04:22 -0700 (PDT)\r
+Received: by mail-pf0-f174.google.com with SMTP id i123so2177638pfg.0\r
+ for <notmuch@notmuchmail.org>; Mon, 27 Jun 2016 21:04:22 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=harple-com.20150623.gappssmtp.com; s=20150623;\r
+ h=mime-version:from:date:message-id:subject:to;\r
+ bh=zYxqydEchTv012DsKhYGkT0xebUgBabW5fCPPetNRmU=;\r
+ b=gPlr+Gib4sVUxz/84qlXsTCQWAAPrEdEn76+xixs2jqsLGO1KBInNh5q7dTsiXq6gI\r
+ nG+B+00nDENwgMtiocl0qOX7jpwLSzEQ6/fBsrtnHiBm1aim0VwnLMJCOmr7ZCH7QkcU\r
+ tvMXdITdu4Ik6CjwVXKSxWnjDvvr/CjMFL7SMsjUgX463qJOoGzwK7sLc6EPRWVxmnnD\r
+ 7noHt1ns9Xy2UPJe40HQRMSZfgHPkBSg/gc2Wl/wG8Qnn+J+6l7lFHSacY4F1nmenMMJ\r
+ IOLmMz/9k6EaYdNtDUAXDguMPE52niCs11bbJJ3e2MckDX6oFMafcfrErAupsM26KQQC\r
+ dkQw==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:mime-version:from:date:message-id:subject:to;\r
+ bh=zYxqydEchTv012DsKhYGkT0xebUgBabW5fCPPetNRmU=;\r
+ b=VginUcCOHz21tniVT9s54HJWkheiaER1g6yzW2Bm9nwaSaihcyuWrKf6UOUPCMlLzH\r
+ gHt2BkX0WlxKwKhpLhwxDo7JoCQuG69+FC+GuQMB1lfTPP8yYJB3cyVswYTAbez+bsp6\r
+ albL04szykbGQKNcNSwPiUlSuZz9NP8OrkerKwG7ZnuRpxwqLhnW27r/vfxC8IgcRYny\r
+ NT3p/wpZRUs9tiaNrRdpKTWK4BLTL6LdZHHZIVL0S03AiYqJeulB5B/WdzvnuW92o9BC\r
+ AEFmHgV4ehJVyr9wtIjlvF5bnAz1BgyqxW8XsYarmkohNwFa5tyT8/pMi127P0ZL7Opi\r
+ Kw/g==\r
+X-Gm-Message-State: ALyK8tKCCulDs/ohI9tVapRIcDljcvibK2JaqQ5tXNEz5R5HK2eNoT1EBLGF011h7avcPCs+lOPkh0icekEqg8o0\r
+X-Received: by 10.98.16.156 with SMTP id 28mr1366573pfq.82.1467086661991; Mon,\r
+ 27 Jun 2016 21:04:21 -0700 (PDT)\r
+MIME-Version: 1.0\r
+Received: by 10.66.8.161 with HTTP; Mon, 27 Jun 2016 21:04:21 -0700 (PDT)\r
+From: Daniel Lee Harple <dlh@harple.com>\r
+Date: Tue, 28 Jun 2016 00:04:21 -0400\r
+Message-ID:\r
+ <CA+7LD1FBuvM8UM1WX-QgKg4haK_iy11MuFZpW3A6oTc8x+9roQ@mail.gmail.com>\r
+Subject: [PATCH] NEWS,\r
+ python: add --libnotmuch-dir option to "setup.py install"\r
+To: notmuch@notmuchmail.org\r
+Content-Type: text/plain; charset=UTF-8\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 28 Jun 2016 04:04:32 -0000\r
+\r
+This change fixes the python bindings on OS X 10.11, which introduced a\r
+feature called System Integrity Protection. The /usr/bin/python\r
+executable has the "restricted" flag set, which means dlopen() requires\r
+an absolute path to the library that is to be loaded.\r
+---\r
+ NEWS                               |  5 +++++\r
+ bindings/python/notmuch/globals.py | 32 ++++++++++++++++++++++++--------\r
+ bindings/python/setup.py           | 17 +++++++++++++++++\r
+ 3 files changed, 46 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/NEWS b/NEWS\r
+index cb6e21c..8164875 100644\r
+--- a/NEWS\r
++++ b/NEWS\r
+@@ -1,6 +1,11 @@\r
+ Notmuch 0.23 (UNRELEASED)\r
+ =========================\r
+\r
++Python Bindings\r
++---------------\r
++\r
++Added `--libnotmuch-dir` option to `setup.py install`\r
++\r
+ Ruby Bindings\r
+ -------------\r
+\r
+diff --git a/bindings/python/notmuch/globals.py\r
+b/bindings/python/notmuch/globals.py\r
+index b1eec2c..499f090 100644\r
+--- a/bindings/python/notmuch/globals.py\r
++++ b/bindings/python/notmuch/globals.py\r
+@@ -17,19 +17,35 @@ along with notmuch.  If not, see\r
+<https://www.gnu.org/licenses/>.\r
+ Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>\r
+ """\r
+\r
++import os\r
+ from ctypes import CDLL, Structure, POINTER\r
+ from notmuch.version import SOVERSION\r
+\r
+-#-----------------------------------------------------------------------------\r
+-#package-global instance of the notmuch library\r
++# This module only exists when this library is installed with setup.py\r
+ try:\r
+-    from os import uname\r
+-    if uname()[0] == 'Darwin':\r
+-        nmlib = CDLL("libnotmuch.{0:s}.dylib".format(SOVERSION))\r
++    from .libnotmuch import LIBNOTMUCH_DIR\r
++except ImportError:\r
++    LIBNOTMUCH_DIR = None\r
++\r
++def load_library():\r
++    if os.uname()[0] == 'Darwin':\r
++        name = 'libnotmuch.{0:s}.dylib'\r
++    else:\r
++        name = 'libnotmuch.so.{0:s}'\r
++    formatted_name = name.format(SOVERSION)\r
++\r
++    if LIBNOTMUCH_DIR is None:\r
++        path = formatted_name\r
+     else:\r
+-        nmlib = CDLL("libnotmuch.so.{0:s}".format(SOVERSION))\r
+-except:\r
+-    raise ImportError("Could not find shared 'notmuch' library.")\r
++        path = os.path.join(LIBNOTMUCH_DIR, formatted_name)\r
++\r
++    try:\r
++        return CDLL(path)\r
++    except:\r
++        raise ImportError('Could not find shared library {!r}.'.format(path))\r
++\r
++# package-global instance of the notmuch library\r
++nmlib = load_library()\r
+\r
+ from .compat import Python3StringMixIn, encode_utf8 as _str\r
+\r
+diff --git a/bindings/python/setup.py b/bindings/python/setup.py\r
+index d986f0c..1594c1d 100644\r
+--- a/bindings/python/setup.py\r
++++ b/bindings/python/setup.py\r
+@@ -21,6 +21,22 @@ Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>\r
+\r
+ import os\r
+ from distutils.core import setup\r
++from distutils.command.install import install as default_install\r
++\r
++class install(default_install):\r
++    user_options = default_install.user_options +\r
+[('libnotmuch-dir=', None, 'path to directory containing libnotmuch')]\r
++\r
++    def initialize_options(self):\r
++        default_install.initialize_options(self)\r
++        self.libnotmuch_dir = None\r
++\r
++    def run(self):\r
++        default_install.run(self)\r
++        if self.dry_run:\r
++            return\r
++        with open(os.path.join(self.install_libbase, 'notmuch',\r
+'libnotmuch.py'), 'w') as f:\r
++            f.write('# This file is auto-generated from setup.py\n')\r
++            f.write('LIBNOTMUCH_DIR = {!r}\n'.format(self.libnotmuch_dir))\r
+\r
+ # get the notmuch version number without importing the notmuch module\r
+ version_file = os.path.join(os.path.dirname(__file__),\r
+@@ -36,6 +52,7 @@ setup(name='notmuch',\r
+       author_email='Sebastian@SSpaeth.de',\r
+       url='https://notmuchmail.org/',\r
+       download_url='https://notmuchmail.org/releases/notmuch-%s.tar.gz'\r
+% __VERSION__,\r
++      cmdclass={'install': install},\r
+       packages=['notmuch'],\r
+       keywords=['library', 'email'],\r
+       long_description='''Overview\r
+-- \r
+2.8.2\r