[zeromq-dev] PyZMQ with Libsodium on Windows?
André Caron
andre.l.caron at gmail.com
Sun Oct 12 05:43:19 CEST 2014
OK. I got it working.
The entire procedure seems to be the following:
1) add a stub <stdint.h> in libsodium and change use of "static inline" for
"static" to prevent VS 2008's compiler from choking;
2) change the "DLL_EXPORT" macro in libzmq to "ZMQ_DLL_EXPORT" and avoid
providing definitions for missing <stdint.h> under VS 2008 when
"HAVE_LIBSODIUM" is defined;
3) modify PyZMQ's "setup.py" file to build libsodium and link libzmq
against libsodium on Windows.
Assuming libsodium's maintainers accept a patch for #1, would you be
willing to accept a pull request to patch libzmq (#2) and then another to
patch PyZMQ (#3)?
Thanks,
André
On Sat, Oct 11, 2014 at 11:14 PM, André Caron <andre.l.caron at gmail.com>
wrote:
> Thanks!
>
> I've now modified the "setup.py" file so that it builds libsodium on
> Windows. However, I'm running into some conflits with ZeroMQ.
>
> First, libzmq defines its own "int8_t" etc. to work around the absence of
> <stdint.h> when building under VS 2008. I'm wondering what the best way to
> fix this is. Maybe add an "#ifndef HAVE_LIBSODIUM" around the typedefs in
> "zeromq/src/stdint.hpp"?
>
> Second, libzmq and libsodium both use the same "DLL_EXPORT" macro to
> control visibility of symbols. When building libzmq, this macro is
> defined, which causes libsodium header files to think they are building
> libsodium. This causes unresolved external linker errors. I think libzmq
> should define a ZMQ_DLL_EXPORT macro which is distinct from that used by
> other libraries.
>
> I'll get something working and follow-up.
>
> Cheers,
>
> André
>
> On Sat, Oct 11, 2014 at 8:58 PM, MinRK <benjaminrk at gmail.com> wrote:
>
>> PyZMQ builds libzmq (and libsodium) as Python extensions, using the
>> compiler associated with Python (hence the need for VC9, the compiler
>> associated with Python.org 2.7). They are built with `setup.py build_ext`.
>>
>> -MinRK
>>
>> On Sat, Oct 11, 2014 at 1:15 PM, André Caron <andre.l.caron at gmail.com>
>> wrote:
>>
>>> Hi again!
>>>
>>> OK, so I managed building libsodium on Windows with MSVC 2008 to match
>>> Python 2.7. Simply required creating a VS solution and include all the
>>> source files. The only problems I ran into are:
>>> 1) <stdint.h> is not provided with MSVC 2008, so I added a stub for it
>>> within the solution in order to build; and
>>> 2) there are some "static inline" function declarations which are
>>> rejected by the compiler, so I removed the "inline" (which is optional).
>>>
>>> So I now have a "libsodium.lib" and a "libsodium.dll".
>>>
>>> Once I have a proof of concept that's working inside PyZMQ, I'll see if
>>> I can get this MSVC 2008 solution included upstream in libsodium.
>>>
>>> However, I'm not familiar with Python bundling process. How should I
>>> provide the libsodium headers, lib & dll files to PyZMQ? What commands do
>>> you run to create the PyZMQ egg and whl bundles once I've made libsodium
>>> available to PyZMQ?
>>>
>>> Thanks,
>>>
>>> André
>>>
>>> On Fri, Oct 10, 2014 at 5:36 AM, Frank Hartmann <soundart at gmx.net>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> Tweetnacl linux integration has been added to libzmq some month ago.
>>>>
>>>> You could try compiling with tweetnacl and VS2008. One(only?) thing
>>>> missing is randombytes() function on windows.
>>>>
>>>> Probably MS has a crypto API somewhere which should make this simple, if
>>>> you trust them. And you can check how libsodium does it.
>>>>
>>>> regards
>>>> Frank
>>>>
>>>> Min RK <benjaminrk at gmail.com> writes:
>>>>
>>>> > For pyzmq, it must work with VC9 (VS2008), for Python 2.7.
>>>> >
>>>> > -MinRK
>>>> >
>>>> >> On Oct 9, 2014, at 18:08, Steven McCoy <steven.mccoy at miru.hk> wrote:
>>>> >>
>>>> >> I think it is easier now as they have more support than just
>>>> MSVC2013 (C99 compat) when crypto was added to ZeroMQ.
>>>> >>
>>>> >>> On 9 October 2014 17:47, MinRK <benjaminrk at gmail.com> wrote:
>>>> >>> It's not bundled simply because I couldn't build it on Windows. If
>>>> you can come up with a simple fix for building bundled libsodium, then I
>>>> would bundle libsodium on Windows.
>>>> >>>
>>>> >>> -MinRK
>>>> >>>
>>>> >>>> On Thu, Oct 9, 2014 at 1:48 PM, André Caron <
>>>> andre.l.caron at gmail.com> wrote:
>>>> >>>> Hi there!
>>>> >>>>
>>>> >>>> I'm trying to secure some PyZMQ communications with the curve
>>>> security features. The code seems straightforward, but when I call
>>>> `zmq.auth.create_certificates()` to generate some keys, I get the following
>>>> exception:
>>>> >>>>
>>>> >>>> zmq.error.ZMQError: Not supported
>>>> >>>>
>>>> >>>> This seems to be due to the absence of libsodium.
>>>> >>>>
>>>> >>>> In the release notes for PyZMQ 14.1.0, I can see that libsodium is
>>>> not bundled with PyZMQ on Windows.
>>>> >>>>
>>>> >>>> First, I'm curious to know why it's not bundled on Windows. If
>>>> it's simply a matter of finding a volunteer, maybe I can pitch in?
>>>> >>>>
>>>> >>>> Second, I'd like to know if there's any known procedure to get it
>>>> running on Windows?
>>>> >>>>
>>>> >>>> Thanks!
>>>> >>>>
>>>> >>>> André
>>>> >>>>
>>>> >>>> _______________________________________________
>>>> >>>> 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
>>>> _______________________________________________
>>>> 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
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20141011/ddfed2fd/attachment.htm>
More information about the zeromq-dev
mailing list