Corey Porter - 2003-03-25

I'm using MySQLdb with a MySQL instance installed in a location not covered by setup.py.  This proved a problem when building MySQLdb.  Is there a well-known solution to this problem that doesn't involve manually adding the paths for MySQL header and library files to setup.py (couldn't find one in the SF forums)? 

My solution involved patching setup.py to take arguments which would tack paths on to the library_dirs and include_dirs variables.  If anybody is interested, here's the patch:

--- setup.py    2002-07-18 12:55:36.000000000 -0700
+++ ../MySQL-python-0.9.2.hacked/setup.py       2003-03-24 22:10:21.000000000 -0800
@@ -99,6 +99,15 @@

"""

+args = sys.argv[:]
+for arg in args:
+    if arg.startswith('--include-dirs='):
+        include_dirs.append(arg.split('=')[1])
+        sys.argv.remove(arg)
+    elif arg.startswith('--library-dirs='):
+        library_dirs.append(arg.split('=')[1])
+        sys.argv.remove(arg)
+
setup (# Distribution meta-data
         name = name,
         version = version,