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