1 Return-Path: <too@guru-group.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id E98EF431FB6
\r
6 for <notmuch@notmuchmail.org>; Tue, 25 Jun 2013 07:37:24 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 0On4hGCDs-pb for <notmuch@notmuchmail.org>;
\r
16 Tue, 25 Jun 2013 07:37:16 -0700 (PDT)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 9452B431FAF
\r
19 for <notmuch@notmuchmail.org>; Tue, 25 Jun 2013 07:37:16 -0700 (PDT)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id 5FB7C1000B2; Tue, 25 Jun 2013 17:37:07 +0300 (EEST)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [RFC PATCH] Python bindings: CDLL("libnotmuch.3.dylib") on Darwin
\r
25 Date: Tue, 25 Jun 2013 17:36:56 +0300
\r
26 Message-Id: <1372171016-11935-1-git-send-email-tomi.ollila@iki.fi>
\r
27 X-Mailer: git-send-email 1.8.0
\r
28 Cc: tomi.ollila@iki.fi
\r
29 X-BeenThere: notmuch@notmuchmail.org
\r
30 X-Mailman-Version: 2.1.13
\r
32 List-Id: "Use and development of the notmuch mail system."
\r
33 <notmuch.notmuchmail.org>
\r
34 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
35 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
36 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
37 List-Post: <mailto:notmuch@notmuchmail.org>
\r
38 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
39 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
41 X-List-Received-Date: Tue, 25 Jun 2013 14:37:25 -0000
\r
43 Use os.uname() to check for 'Darwin' and load "libnotmuch.3.dylib"
\r
44 instead of "libnotmuch.so.3" if that is the case.
\r
47 This is followup to thread starting from
\r
49 id:1369540418-94177-1-git-send-email-Julian@GrayVines.com
\r
51 For anyone interested: this is basically no-overhead addition as ctypes
\r
52 already loads os module (is "available" as ctypes._os) -- Comparison using
\r
53 strace(1) showed that uname system call is used in addition to other processing.
\r
55 This patch is modeled after _lb_'s comments on IRC:
\r
57 < _lb_> nmlib = CDLL("libnotmuch.so.3") needs to be replaced with
\r
58 nmlib = CDLL("libnotmuch.3.dylib") in OSX
\r
59 < _lb_> Works like a charm! Mmm... I'll have to subscribe to the list
\r
60 to send the patch...
\r
61 < _lb_> I guess the quid of the question is to have an os detection
\r
62 if so it loads the right lib?
\r
64 ... a few days ago, but the patch didn't arrive yet ;D
\r
66 I tested that this still works on Linux, but did not test on Mac OS X;
\r
67 also I did not think much how to handle the importing and the if test.
\r
69 Anyone using Mac care to take over -- you are probably more interested
\r
70 of getting this thing to work :D
\r
74 bindings/python/notmuch/globals.py | 6 +++++-
\r
75 1 file changed, 5 insertions(+), 1 deletion(-)
\r
77 diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py
\r
78 index c7632c3..2deb87c 100644
\r
79 --- a/bindings/python/notmuch/globals.py
\r
80 +++ b/bindings/python/notmuch/globals.py
\r
81 @@ -22,7 +22,11 @@ from ctypes import CDLL, Structure, POINTER
\r
82 #-----------------------------------------------------------------------------
\r
83 #package-global instance of the notmuch library
\r
85 - nmlib = CDLL("libnotmuch.so.3")
\r
86 + from os import uname
\r
87 + if uname()[0] == 'Darwin':
\r
88 + nmlib = CDLL("libnotmuch.3.dylib")
\r
90 + nmlib = CDLL("libnotmuch.so.3")
\r
92 raise ImportError("Could not find shared 'notmuch' library.")
\r