[Pythonmac-SIG] Re: Install MySQLdb module on mac os x (Dieter Gyselinck)

Russell E Owen owen@astro.washington.edu
Mon, 18 Nov 2002 09:14:01 -0800


>From: Dieter Gyselinck <dietergyselinck@pandora.be>
>...
>     I'm trying to install the python MySQLdb module on os x 10.2 but 
>when I try to run 'setup.py build' I get this error message :
>ld: can't locate file for: -lmysqlclient
>error: command 'gcc' failed with exit status 1
>
>I have installed binary mysql-3.23.52 package and it seems to be 
>working fine, I can access my db via php.  I am trying to run the 
>MySQL-python-0.9.2 setup.  I have changed 'thread_safe_library' to 
>'NO' but that does not solve the problem.  Anyone can help me out 
>with this problem???

Here's how I mySQL running with Python:

1) I used Marc Liyanage's mySQL binary and installer. This put 
everything in  /usr/local/mysql (actually that's a link to a similar 
item with the version # appended).

2) I got MySQL-python-0.9.2 and found I had to modify setup.py to get 
it to work. It had the problem with thread_safe_library that you 
already noted and also was missing the appropriate directories from 
setup.py. Here are mininal fixes:

# set this to YES if you have the thread-safe mysqlclient library
thread_safe_library = NO

...

# include files and library locations should cover most platforms
include_dirs = [
     '/usr/include/mysql',
     '/usr/local/include/mysql',
     '/usr/local/mysql/include',  # added by RO for MacOS X
     '/usr/local/mysql/include/mysql' # is this real? it looks suspicious
     ]
library_dirs = [
     '/usr/lib/mysql',
     '/usr/local/lib/mysql',
     '/usr/local/mysql/lib',  # added by RO for MacOS X
     '/usr/local/mysql/lib/mysql' # is this real? it looks suspicious
     ]

My full setup.py also filters the two directory lists above to remove 
any that don't exist -- that is entirely optional but saves a lot of 
warning messages. I sent email to the developer of MySQL-python-0.9.2 
that included my full setup.py; we'll see if it gets incorporated. If 
you want a copy, let me know and I'll email it to you; I didn't want 
to clutter up the mailing list.

-- Russell