Hi,
As an added incentive, I'll commit to donating £50 to the project when this bug gets fixed and pushed out in a release! :-)
This issue affects all versions of MySQL-python.
Basically setup_posix.py doesn't use all the linker flags given by mysql_config when building _mysql.so, and only passes through "-l" and "-L" flags. On platforms where MySQL has been installed in a non-standard location, mysql_config may have been be configured to return a -R flag, for example:
-L/opt/mysql/5.5/lib -R/opt/mysql/5.5/lib -lmysqlclient -lthread -lsocket -lz -lnsl -lm -lrt
The -R flag tells the linker to encode the given run path in the resulting binary or shared object, so that it can find the libraries in the non-standard location:
[12] RUNPATH /opt/mysql/5.5/lib
[13] RPATH /opt/mysql/5.5/lib
Unfortunately since setup_posix.py strips out these -R flags, the resulting _mysql.so object when loaded can't find the MySQL libraries.
It's possible to work around this with an LD_LIBRARY_PATH or by modifying the systems runtime linker search path, however this isn't always desirable or recommended.
I guess the logic behind setup_posix.py filtering the compiler flags given by mysql_config is to strip out optimisation flags/unnecessary flags, but the -R flag should be passed through; not passing this through should definitely be considered a bug, since it will trip up many users who are on otherwise correctly configured systems, but where the MySQL libraries aren't in the standard system library search path.
It's a trivial change to setup_posix.py to pass the flag through, and I can supply a patch if desirable.
Thanks for your continued work on MySQL-python!
Kind Regards,
Alasdair