7 de abril de 2014

Installing MySQL-Python in Mac OS X Mavericks

If you are in Mac OS X Mavericks and while trying to install MySQL-Python you run into this error:

running build_ext
building '_mysql' extension
creating build/temp.macosx-10.9-intel-2.7
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing -arch x86_64
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1
view raw gistfile1.sh hosted with ❤ by GitHub


This is a what makes the trick:

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
view raw gistfile1.sh hosted with ❤ by GitHub


Then, pip works its way towards installing MySQL-Python OK:

(....)
#define HAVE_WCSCOLL
^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:906:9: note: previous definition is here
#define HAVE_WCSCOLL 1
^
_mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (how < 0 || how >= sizeof(row_converters)) {
~~~ ^ ~
3 warnings generated.
cc -bundle -undefined dynamic_lookup -Wl,-F. -Qunused-arguments -Qunused-arguments build/temp.macosx-10.9-intel-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -o build/lib.macosx-10.9-intel-2.7/_mysql.so -arch x86_64
Successfully installed MySQL-python
Cleaning up...
view raw gistfile1.sh hosted with ❤ by GitHub


Voilà!