Re: [notmuch] SWIG (and particularly Python) bindings
authorBen Gamari <bgamari@gmail.com>
Wed, 30 Dec 2009 16:10:31 +0000 (11:10 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:35:56 +0000 (09:35 -0800)
70/11d744c79432291c36a821dbbfbb7270804e9c [new file with mode: 0644]

diff --git a/70/11d744c79432291c36a821dbbfbb7270804e9c b/70/11d744c79432291c36a821dbbfbb7270804e9c
new file mode 100644 (file)
index 0000000..c65a706
--- /dev/null
@@ -0,0 +1,133 @@
+Return-Path: <bgamari@gmail.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 olra.theworths.org (Postfix) with ESMTP id 5A154431FBC\r
+       for <notmuch@notmuchmail.org>; Wed, 30 Dec 2009 08:10:40 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 3TuFB+uMXKvA for <notmuch@notmuchmail.org>;\r
+       Wed, 30 Dec 2009 08:10:39 -0800 (PST)\r
+Received: from qw-out-1920.google.com (qw-out-1920.google.com [74.125.92.149])\r
+       by olra.theworths.org (Postfix) with ESMTP id 419A6431FAE\r
+       for <notmuch@notmuchmail.org>; Wed, 30 Dec 2009 08:10:39 -0800 (PST)\r
+Received: by qw-out-1920.google.com with SMTP id 5so2079109qwc.32\r
+       for <notmuch@notmuchmail.org>; Wed, 30 Dec 2009 08:10:35 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=domainkey-signature:received:received:content-type:subject:from:to\r
+       :in-reply-to:references:date:message-id:user-agent\r
+       :content-transfer-encoding;\r
+       bh=MvpQ/MeNo7Irv5MeYzTEXHmbI8Vv79zq2121dCgIQcc=;\r
+       b=M4dJtNKkTtcCPrtcl7aoJx4S3jd66/T8klY4zLCsHOIozfeKCuX4vkHRIz/g3y8SLA\r
+       H/j1AXXDgOKNHT1Lyc1YxpxN8zsG1LzpRxKg8JXWGaZHJzcXVfL1rbd0D+EFke9NEzdA\r
+       ycD4vKcgEJO1zGrwDwu6BLplpkDAgmr8xu3Ps=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
+       h=content-type:subject:from:to:in-reply-to:references:date:message-id\r
+       :user-agent:content-transfer-encoding;\r
+       b=t5S04f//g+RGJIuIlfu39h/htW/o+dw4i7QAcGjnqK2qB/iSwsGj1Jtsg+1rYtSfF/\r
+       yh6TSHGNPdPRm18pMagsb31MHmzHWxm4ujt7rFYfROmoF14YyuhL9dckQUCA47ySwt6O\r
+       76tE7BlfWLrnYH26ZHB+Rwg4XLpKAEh/zPhRw=\r
+Received: by 10.224.87.197 with SMTP id x5mr8763448qal.272.1262189435127;\r
+       Wed, 30 Dec 2009 08:10:35 -0800 (PST)\r
+Received: from localhost (c-24-61-223-13.hsd1.nh.comcast.net [24.61.223.13])\r
+       by mx.google.com with ESMTPS id 21sm12233142qyk.12.2009.12.30.08.10.33\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Wed, 30 Dec 2009 08:10:33 -0800 (PST)\r
+Content-Type: text/plain; charset=UTF-8\r
+From: Ben Gamari <bgamari@gmail.com>\r
+To: notmuch <notmuch@notmuchmail.org>\r
+In-reply-to: <20091230115223.1b3472a1@hikari>\r
+References: <1262078148-sup-7891@ben-laptop> <20091230115223.1b3472a1@hikari>\r
+Date: Wed, 30 Dec 2009 11:10:31 -0500\r
+Message-Id: <1262188858-sup-2372@ben-laptop>\r
+User-Agent: Sup/git\r
+Content-Transfer-Encoding: 8bit\r
+Subject: Re: [notmuch] SWIG (and particularly Python) bindings\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 30 Dec 2009 16:10:40 -0000\r
+\r
+Excerpts from Adrian Perez de Castro's message of Wed Dec 30 05:52:23 -0500 2009:\r
+> On Tue, 29 Dec 2009 04:16:43 -0500, Ben wrote:\r
+> \r
+> > Regardless, I thought it might be nice to have access to the notmuch\r
+> > backend from a language other than C (preferably my high-level language\r
+> > of choice, python) [...]\r
+> \r
+> Funny, I was just doing the same: a Python binding. Haha, so now we have\r
+> two just-backed Python bindings. What should we do?\r
+\r
+Heh, it's a small world, eh?\r
+\r
+> \r
+> > [...] To this end, I took a few hours today acquainting\r
+> > myself with SWIG and produced these bindings for Python. Unfortunately,\r
+> > it doesn't appear that SWIG has particularly good support for\r
+> > object-oriented C [...]\r
+> \r
+> I already used SWIG sometimes in the past (and did not like it a lot), so\r
+> my binding is using Cython [*] (which is exactly like Pyrex plus some extra\r
+> features), so the binding is partly manual.\r
+> \r
+I liked that SWIG would give us coverage for a multitude of languages\r
+with little work. Unfortunately, getting an object oriented interface\r
+requires wrapping the functions exposed by SWIG. Nevertheless, I think\r
+being able to generically hide the ugliness of the binding glue itself\r
+is quite nice. Moveover, there's effectively no SWIG interface code to\r
+maintain.  It's literally just a [#%]include "notmuch.h". The rest is\r
+all the Python wrapper. This seems like a nice binding model, short of\r
+SWIG doing everything (the developers at some point might add support\r
+for proper wrapping of object-oriented C code).\r
+\r
+> > While the bindings are currently in the form of a patch to notmuch\r
+> > (creating a top-level swig directory in the source tree), they could\r
+> > certainly be moved out-of-tree if the powers that be don't feel it\r
+> > appropriate to include them. [...]\r
+> \r
+> Same here, see attached patch. It is currently unfinished, and I was just\r
+> about to add support for iterating notmuch_threads_t and other similar\r
+> structures. I can also publish a Git repo with the entire branch, just\r
+> drop me a line if you want me to do that.\r
+> \r
+In my approach, I just used the iterator protocol.\r
+\r
+> > [...] Unfortunately, the build system is currently almost entirely\r
+> > independent from the notmuch build system. If  these are to be\r
+> > included in-tree, I would be curious to hear people have\r
+> > to say about how we might integrate it into the sup build system.\r
+>                                                   ^^^\r
+> (Mmmh, I suppose you mean "notmuch build system" there :P)\r
+\r
+Heh, yep.\r
+\r
+> \r
+> Mine is a little more cooked, as I have added a distutils "setup.py"\r
+> script. The bad news is that Python modules need to be compiled as\r
+> relocatable object files (-fPIC to teh rescue!), and the linker will\r
+> refuse to link the generated code with "notmuch.a" -- so I am instructing\r
+> distutils to compile *all* sources again. Not nice.\r
+> \r
+In my patch I simple I modified the LDFLAGS to include -fPIC. Not sure if\r
+that's an acceptable option or not.\r
+\r
+> BTW, I think that if more bindings start to appear, Notmuch might be built\r
+> as a shared library, to avoid duplicating it everywhere. One option may be\r
+> using *just* libtool but not the rest of auto-foo tools (for the record:\r
+> I agree with Carl that they are slow and wicked).\r
+> \r
+I think you're probably right. Libtool is probably the best option here\r
+(Despite the fact that I, too, have a bitter hatred of autotools).\r
+\r
+Cheers,\r
+- Ben\r