* [RFC PATCH] Python bindings: CDLL("libnotmuch.3.dylib") on Darwin
@ 2013-06-25 14:36 Tomi Ollila
2013-06-25 15:21 ` Justus Winter
0 siblings, 1 reply; 3+ messages in thread
From: Tomi Ollila @ 2013-06-25 14:36 UTC (permalink / raw)
To: notmuch; +Cc: tomi.ollila
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] Python bindings: CDLL("libnotmuch.3.dylib") on Darwin
2013-06-25 14:36 [RFC PATCH] Python bindings: CDLL("libnotmuch.3.dylib") on Darwin Tomi Ollila
@ 2013-06-25 15:21 ` Justus Winter
[not found] ` <m2ppuvq3iv.fsf@guru.guru-group.fi>
0 siblings, 1 reply; 3+ messages in thread
From: Justus Winter @ 2013-06-25 15:21 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: tomi.ollila
Quoting Tomi Ollila (2013-06-25 16:36:56)
> 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
Looks good, though I'd prefer not to do the from..import
thing. os.uname is just as short and more concise, you can see where
the uname function comes from.
If anyone on OSX confirms that this works I'll merge the patch.
Justus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-09 6:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-25 14:36 [RFC PATCH] Python bindings: CDLL("libnotmuch.3.dylib") on Darwin Tomi Ollila
2013-06-25 15:21 ` Justus Winter
[not found] ` <m2ppuvq3iv.fsf@guru.guru-group.fi>
2013-07-09 6:41 ` Justus Winter
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).