tonysimpson / nanomsg-python

nanomsg wrapper for python with multiple backends (CPython and ctypes) should support 2/3 and Pypy
MIT License
382 stars 85 forks source link

Is this maintained? #82

Closed SpaceMonkeyForever closed 1 year ago

SpaceMonkeyForever commented 1 year ago

I'm trying to use nanomsg because ZMQ doesn't have a good implementation in Rust. However, I'm having trouble finding the Python library. I cannot compile pynng on my Mac M1 and this library has only one version (1.0.0) available in PIP and doesn't have any description.

Are you still maintaining this library or are there any good Python bindings?

tonysimpson commented 1 year ago

As far as I know this is still the best option for Python binding. As for if this library is maintained you'd be a better judge of that than me.

SpaceMonkeyForever commented 1 year ago

Thanks for your reply, Tony. I'm getting the following error when compiling on Mac M1:

[ 98%] Building C object src/CMakeFiles/nng.dir/supplemental/http/http_server.c.o
[100%] Linking C static library ../libnng.a
[100%] Built target nng
creating build
creating build/lib.macosx-12-arm64-cpython-310
creating build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/options.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/_version.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/__init__.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/_aio.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/tls.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/sockaddr.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/exceptions.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/nng.py -> build/lib.macosx-12-arm64-cpython-310/pynng
running build_ext
generating cffi module 'build/temp.macosx-12-arm64-cpython-310/pynng._nng.c'
creating build/temp.macosx-12-arm64-cpython-310
build_nng_lib()
building 'pynng._nng' extension
creating build/temp.macosx-12-arm64-cpython-310/build
creating build/temp.macosx-12-arm64-cpython-310/build/temp.macosx-12-arm64-cpython-310
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Inng/include -I/Users/spacemonkey/Projects/mangotrader/mangotrader/env/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c build/temp.macosx-12-arm64-cpython-310/pynng._nng.c -o build/temp.macosx-12-arm64-cpython-310/build/temp.macosx-12-arm64-cpython-310/pynng._nng.o
clang -bundle -undefined dynamic_lookup build/temp.macosx-12-arm64-cpython-310/build/temp.macosx-12-arm64-cpython-310/pynng._nng.o ./nng/build/libnng.a ./mbedtls/prefix/lib/libmbedtls.a ./mbedtls/prefix/lib/libmbedx509.a ./mbedtls/prefix/lib/libmbedcrypto.a -lpthread -latomic -o build/lib.macosx-12-arm64-cpython-310/pynng/_nng.abi3.so
ld: library not found for -latomic
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit code 1

The main error ld: library not found for -latomic seems to be resolved by removing -latmoice from the linking step. So, instead, I can do:

clang -bundle -undefined dynamic_lookup build/temp.macosx-12-arm64-cpython-310/build/temp.macosx-12-arm64-cpython-310/pynng._nng.o ./nng/build/libnng.a ./mbedtls/prefix/lib/libmbedtls.a ./mbedtls/prefix/lib/libmbedx509.a ./mbedtls/prefix/lib/libmbedcrypto.a -lpthread ~-latomic~ -o build/lib.macosx-12-arm64-cpython-310/pynng/_nng.abi3.so

Then I can python setup.py install and I can import it fine. I'm testing now whether it works

SpaceMonkeyForever commented 1 year ago

I'm sorry, I was not paying attention to what I was posting. Apologies. I also realised that NNG is not the same as nanomsg and it seems to be better to stick to the newer NNG (so the only binding is pynng)