Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'pip3 install -e .' fails on MacOS #89

Open
The-QA-Geek opened this issue Aug 6, 2021 · 12 comments
Open

'pip3 install -e .' fails on MacOS #89

The-QA-Geek opened this issue Aug 6, 2021 · 12 comments

Comments

@The-QA-Geek
Copy link

At least on my M1, 'pip3 install -e .' fails with this error:

'clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -Inng/include -I/Users/leslie/.pyenv/versions/3.9.6/envs/python-build/include -I/Users/leslie/.pyenv/versions/3.9.6/include/python3.9 -c build/temp.macosx-11.4-arm64-3.9/pynng._nng.c -o build/temp.macosx-11.4-arm64-3.9/build/temp.macosx-11.4-arm64-3.9/pynng._nng.o
clang -bundle -undefined dynamic_lookup -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/readline/lib -L/Users/leslie/.pyenv/versions/3.9.6/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/readline/lib -L/Users/leslie/.pyenv/versions/3.9.6/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib build/temp.macosx-11.4-arm64-3.9/build/temp.macosx-11.4-arm64-3.9/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-11.4-arm64-3.9/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

'python setup.py bdist_wheel' fails with the same missing library.

I don't know whether that is a missing source file or a missing dependency on my Mac (it looks more like a missing dependency on my Mac), but I haven't been able to find any information on the 'atomic' library. If someone could explain how to fix this I would greatly appreciate it, and it might help other people using the M1 Macs.

@The-QA-Geek
Copy link
Author

Would anyone like to be paid to solve this? If so, how much would you charge and how long will it take?

@codypiersall
Copy link
Owner

Thanks for opening an issue here—a month ago! Sorry for the lack of an update. Things have been busy.

The problem I believe is the hacky solution I came up with to track the system libraries that need to be linked in order to use pynng. Even when I did the fix i noted how bad it was 1a7ad77: commit message was "Fix (still really bad) heuristic for when to link libatomic."

The better way is to somehow use CMake to determine what libraries need to be linked with—possible build pynng as a shared library.

For your situation, for now, possibly it will work to just not link libatomic. If you change line 32 of build_pynng.py to not add libatomic it may build on the new M1. I don't have a Mac, let alone one of the new ones, so I can't test it... but hopefully it will work!

I'm not at a point where I can spend much time on open source at the present, and although I genuinely appreciate the offer of payment my main problem right now is time, not interest or money. Of course I can't speak for anyone else, others are free to do as they wish!

@The-QA-Geek
Copy link
Author

The-QA-Geek commented Sep 4, 2021

Sweet; that lets me build pynng on an M1 Mac. I have a bit more work to do before I can actually pass messages through pynng to a receiver; that will confirm that everything really works. I should be able to do that on Monday.

I had already tried 'brew install libatomic_ops', but that didn't help.

I will post updated status, pass or fail, in a few days.

@The-QA-Geek
Copy link
Author

Commenting out Lines 32 and 33 works; I was able to send and receive messages. Thank you very much for the help.

@regcs
Copy link
Contributor

regcs commented Nov 3, 2021

We are currently also struggling with that M1 issue. Is there any way to build pynng for M1 from an Intel Mac?

@The-QA-Geek
Copy link
Author

I was able to build it on my M1 Mac simply by commenting out lines 32 and 33. I didn't have to install any other libraries or special tools.

@regcs
Copy link
Contributor

regcs commented Nov 4, 2021

That is good to know. But I don't have a M1 Mac available and I am wondering: How would I build a wheel for it from an Intel Mac?

@regcs
Copy link
Contributor

regcs commented Nov 7, 2021

Ok, I found a way. Commenting lines 32 and 33 above out and using a GitHub Action I was now able to cross-compile a "universal2" wheel, which works on both Intel and M1 chips:

https://github.com/regcs/pynng/blob/master/.github/workflows/cibuildwheel.yml

@codypiersall: Would it make sense to prepare a pull request for that cross-compilation? Then you could make a new release and upload the M1 compatible wheels to PyPI so that others could pip install pynng.

@janosh
Copy link

janosh commented Jan 19, 2022

@regcs Thanks for figuring this out. A PR that fixes this would be great!

@lingster
Copy link

@janosh : I have just submitted PR #100 to fix this issue.

regcs added a commit to regcs/pynng that referenced this issue Apr 13, 2022
Enables Apple Silicon compatability (codypiersall#88, codypiersall#89) and Python 3.10.
@regcs
Copy link
Contributor

regcs commented Apr 13, 2022

@janosh: Sorry for the late response!😅

Since @lingster's PR #100 seems to fail, I created a new PR #102. This also adds support for Python 3.10 (#98) in addition to Apple Silicon compatibility. I hope @codypiersall finds some time to merge the PR and upload the new wheels to PyPi so that it can be pip installed.

@codypiersall
Copy link
Owner

If you can post more of the build log I might be able to help. I don't have a Mac so I can't test anything on my end. The chunk you posted doesn't actually have the error in it, unfortunately, at least not the specifics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants