[zeromq-dev] CZMQ Python Bindings

Michel Pelletier pelletier.michel at gmail.com
Fri Oct 11 17:40:25 CEST 2013


Thanks Felipe!  I appreciate the kind words and I hope you enjoy your
vacation.  I'm really enjoying the cffi module, it seems like one of those
cool projects that creates a convergence in the evolution of software.

For those who are interested I've made some more progress:

There's an initial start at wrapping the low level zmq functions in
pyczmq.zmq.  This was done largely to expose the ability to do "zero copy"
messages support for which was removed from czmq.

New code format permits automatic sphinx documentation, which is now hosted
via an automatic git commit hook thanks to readthedocs.org, for example:
http://pyczmq.readthedocs.org/en/latest/pyczmq.html#module-pyczmq.zsocket

I'm going to try and get all the loose ends wrapped up this week and drop a
lot more tests in.

-Michel




On Thu, Oct 10, 2013 at 3:42 PM, Felipe Cruz <felipecruz at loogica.net> wrote:

> Hi Michael.
>
> Unfortunately there's no such tool for python cffi. Even pyzmq is a mix of
> cython and cffi, both manually coded.
>
> Anyway, I'm very interested in provide access for features like zbeacon
> and projects like FileMQ to high level languages such as Python. There are
> a lot of opportunities to be explored when those features become available.
>
> I'm on vacation right now but ASAP, I would like to participate in make
> this moving forward!
>
> great work BTW
>
> regards,
> Felipe
>
>
>
>
>
> 2013/10/9 Pieter Hintjens <ph at imatix.com>
>
>> I've never heard of such a tool but it seems worth making... I'll have
>> a whack at it when I get bored later this week.
>>
>> On Wed, Oct 9, 2013 at 9:24 PM, Michel Pelletier
>> <pelletier.michel at gmail.com> wrote:
>> > Automation would be be great, and not just for Python, making the
>> wrapper
>> > was a bit tedious, although completely doable.  I'm surprised there
>> isn't
>> > something like SWIG but for libffi, where you can point a .h file and
>> some
>> > kind of specfile at a tool that dumps the correct bindings incantation
>> for
>> > various languages.  Maybe there is such a tool?  A quick google didn't
>> > reveal much to me.
>> >
>> > -Michel
>> >
>> >
>> > On Wed, Oct 9, 2013 at 12:27 AM, Pieter Hintjens <ph at imatix.com> wrote:
>> >>
>> >> Hi Michel,
>> >>
>> >> This is great fun! I'm going to look at what you did since I'd like to
>> >> try generating Python wrappers for our standardish C APIs (FileMQ,
>> >> Zyre, for instance).
>> >>
>> >> -Pieter
>> >>
>> >> On Wed, Oct 9, 2013 at 4:28 AM, Michel Pelletier
>> >> <pelletier.michel at gmail.com> wrote:
>> >> > Wanting to know more about Python and CFFI, I decided to do a
>> >> > straightforward wrap job for Python around the CZMQ C API.  I have it
>> >> > reasonable complete enough to write some simple code and tests.  I've
>> >> > pushed
>> >> > it up to github:
>> >> >
>> >> > https://github.com/michelp/pyczmq
>> >> >
>> >> > Most of the core functionality, zctx, zsocket, zsockopt, zpoller,
>> zmsg,
>> >> > zframe, zstr, zloop, zbeacon, zcert, zauth, are exposed as both
>> straight
>> >> > wrappers around the C interface as well as some namespaced functions
>> >> > that
>> >> > provide a high level functional interface (eg, turning cdata char *
>> into
>> >> > python byte strings, etc).  For example:
>> >> >
>> >> >
>> >> >     ctx = zctx.new()
>> >> >     push = zsocket.new(ctx, zsocket.PUSH)
>> >> >     pull = zsocket.new(ctx, zsocket.PULL)
>> >> >     zsocket.bind(push, 'inproc://test')
>> >> >     zsocket.connect(pull, 'inproc://test')
>> >> >     zstr.send(push, 'foo')
>> >> >     assert zstr.recv(pull) == 'foo'
>> >> >     zstr.send(push, 'bar')
>> >> >     zsocket.poll(pull, 1)
>> >> >     assert zstr.recv_nowait(pull) == 'bar'
>> >> >
>> >> >
>> >> >
>> >> > There's also a first stab at providing an OO interface in the form of
>> >> > Context, Socket, Beacon and Loop classes.  Here's a working example:
>> >> >
>> >> >     ctx = Context()
>> >> >     pub = ctx.socket('PUB')
>> >> >     sub = ctx.socket('SUB')
>> >> >     sub.set_subscribe('')
>> >> >     pub.bind('inproc://zoop')
>> >> >     sub.connect('inproc://zoop')
>> >> >     pub.send('foo')
>> >> >     sub.poll(1)
>> >> >     assert sub.recv() == 'foo'
>> >> >
>> >> >
>> >> > This is a work in progress, it's useful enough now to create socket
>> and
>> >> > messages and send and receive data.  I'd certainly love any form of
>> >> > help,
>> >> > just send me a pull request.  Featured desired are way more tests!
>>  And
>> >> > of
>> >> > course any missing functions that need wrapping, or new
>> functionality.
>> >> >
>> >> > Thanks and enjoy,
>> >> >
>> >> > -Michel
>> >> >
>> >> > _______________________________________________
>> >> > zeromq-dev mailing list
>> >> > zeromq-dev at lists.zeromq.org
>> >> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> >> >
>> >> _______________________________________________
>> >> zeromq-dev mailing list
>> >> zeromq-dev at lists.zeromq.org
>> >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> >
>> >
>> >
>> > _______________________________________________
>> > zeromq-dev mailing list
>> > zeromq-dev at lists.zeromq.org
>> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> >
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>
>
>
> --
> Felipe Cruz
> http://about.me/felipecruz
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131011/e406c190/attachment.htm>


More information about the zeromq-dev mailing list