Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build python gevent on mac osx 10.10

Tags:

python

pip

gevent

Synopsis: pip install gevent doesn't work.

Digging down, I downloaded the gevent .tar.gz and ran the build manually: python setup.py build, got the same error:

running build
running build_py
running build_ext
building 'gevent.core' extension
clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -U__llvm__ -DLIBEV_EMBED=1 -DEV_COMMON= -DEV_CLEANUP_ENABLE=0 -DEV_EMBED_ENABLE=0 -DEV_PERIODIC_ENABLE=0 -Ibuild/temp.macosx-10.10-x86_64-2.7/libev -Ilibev -I/Users/travisjohnson/.pyenv/versions/2.7.5/include/python2.7 -c gevent/gevent.core.c -o build/temp.macosx-10.10-x86_64-2.7/gevent/gevent.core.o
In file included from gevent/gevent.core.c:313:
In file included from gevent/libev.h:2:
...
29 various compiler warnings
...
29 warnings generated.
clang -bundle -bundle_loader python.exe -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/Users/travisjohnson/.pyenv/versions/2.7.5/lib -U__llvm__ build/temp.macosx-10.10-x86_64-2.7/gevent/gevent.core.o -o build/lib.macosx-10.10-x86_64-2.7/gevent/core.so
ld: file not found: python.exe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1

My first thought is "It looks like it's telling clang to link python.exe into something", which initially I thought was nonsense (this isn't windows), but: https://docs.python.org/devguide/setup.html#unix says python.exe is the default name for python after building (because of case insensitivity), so now I don't know.

I've been digging at this for hours, and don't have a next step. I found something similar (I think) on a different project, but there was no explanation on the cause or what fixed it, just that it was fixed (I've checked that my xcode and developer tools etc are up to date)

I'm at a total loss for next steps here, could someone point me in the right direction?

EDIT: Digging a bit more into running the build manually step by step, I did get this specific step to not error-out by:

  • Finding the location of the python binary (not the shim used by pyenv)
  • Manually running the clang command listed in the log, but replacing python.exe with the path to my python binary, ie: /Users/username/.pyenv/versions/adid/bin/python2.7

So it seems it isn't getting some correct path to the python binary? Unfortunately I don't know the remainder of the build process so I can't keep going on my own, and I don't know how to place this path correction into the process run by setup.py. I didn't have these issues before updating to 10.10 (could have been something else, it's been a few days and I've done other stuff), so I don't know why this is only a new issue.

like image 242
ThisGuy Avatar asked Dec 02 '14 21:12

ThisGuy


1 Answers

Apparently this is an issue with my virtualenv manager:

https://github.com/yyuu/pyenv/issues/273

Unable to install compiled Python modules under pyenv on OS X 10.10 is the name of the issue.

EDIT: No it isn't.

This is a bug with python. The way python did os version comparisons in OSX was naive, and broke with the double digit in 10.10, where it would then think you were on a much older OSX. This can often go unnoticed, except when installing compiled modules (where it's used to make some decisions).

This was fixed here: https://bugs.python.org/issue21811

I don't remember if 2.7.7 or 2.7.8 was the version with the released fix (but it was one of them), but the end result is you can't use older versions of 2.7 on OSX 10.10 or newer. If you're running into this issue then personally I'd push to upgrade the python version used ;) (2.7.11 has some awesome ssl improvements anyways).

like image 88
ThisGuy Avatar answered Sep 20 '22 13:09

ThisGuy