From 3ef27cf80261eea8e3530536f1749916a848f07a Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Tue, 25 Jun 2013 17:36:56 +0300 Subject: [PATCH] [RFC PATCH] Python bindings: CDLL("libnotmuch.3.dylib") on Darwin --- f8/4dfbcbc3b83382cb8d584abeee60fc205e34a0 | 96 +++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 f8/4dfbcbc3b83382cb8d584abeee60fc205e34a0 diff --git a/f8/4dfbcbc3b83382cb8d584abeee60fc205e34a0 b/f8/4dfbcbc3b83382cb8d584abeee60fc205e34a0 new file mode 100644 index 000000000..102747c4c --- /dev/null +++ b/f8/4dfbcbc3b83382cb8d584abeee60fc205e34a0 @@ -0,0 +1,96 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id E98EF431FB6 + for ; Tue, 25 Jun 2013 07:37:24 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 0On4hGCDs-pb for ; + Tue, 25 Jun 2013 07:37:16 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 9452B431FAF + for ; Tue, 25 Jun 2013 07:37:16 -0700 (PDT) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 5FB7C1000B2; Tue, 25 Jun 2013 17:37:07 +0300 (EEST) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: [RFC PATCH] Python bindings: CDLL("libnotmuch.3.dylib") on Darwin +Date: Tue, 25 Jun 2013 17:36:56 +0300 +Message-Id: <1372171016-11935-1-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 1.8.0 +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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, 25 Jun 2013 14:37:25 -0000 + +Use os.uname() to check for 'Darwin' and load "libnotmuch.3.dylib" +instead of "libnotmuch.so.3" if that is the case. +--- + +This is followup to thread starting from + + id:1369540418-94177-1-git-send-email-Julian@GrayVines.com + +For anyone interested: this is basically no-overhead addition as ctypes +already loads os module (is "available" as ctypes._os) -- Comparison using +strace(1) showed that uname system call is used in addition to other processing. + +This patch is modeled after _lb_'s comments on IRC: + +< _lb_> nmlib = CDLL("libnotmuch.so.3") needs to be replaced with + nmlib = CDLL("libnotmuch.3.dylib") in OSX +< _lb_> Works like a charm! Mmm... I'll have to subscribe to the list + to send the patch... +< _lb_> I guess the quid of the question is to have an os detection + if so it loads the right lib? + +... a few days ago, but the patch didn't arrive yet ;D + +I tested that this still works on Linux, but did not test on Mac OS X; +also I did not think much how to handle the importing and the if test. + +Anyone using Mac care to take over -- you are probably more interested +of getting this thing to work :D + +Tomi + + bindings/python/notmuch/globals.py | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py +index c7632c3..2deb87c 100644 +--- a/bindings/python/notmuch/globals.py ++++ b/bindings/python/notmuch/globals.py +@@ -22,7 +22,11 @@ from ctypes import CDLL, Structure, POINTER + #----------------------------------------------------------------------------- + #package-global instance of the notmuch library + try: +- nmlib = CDLL("libnotmuch.so.3") ++ from os import uname ++ if uname()[0] == 'Darwin': ++ nmlib = CDLL("libnotmuch.3.dylib") ++ else: ++ nmlib = CDLL("libnotmuch.so.3") + except: + raise ImportError("Could not find shared 'notmuch' library.") + +-- +1.8.0 + -- 2.26.2