Made setup.py usable for Windows again. You must set

the mysqlroot environment variable or patch to make
it actually work.
This commit is contained in:
adustman
2005-01-23 06:56:55 +00:00
parent 26b64c6af0
commit aac9787605

View File

@ -30,7 +30,7 @@ import sys
from distutils.core import setup from distutils.core import setup
from distutils.extension import Extension from distutils.extension import Extension
mysqlclient = os.getenv('mysqlclient', 'mysqlclient') mysqlclient = os.getenv('mysqlclient', 'mysqlclient_r')
mysqloptlibs = os.getenv('mysqloptlibs', '').split() mysqloptlibs = os.getenv('mysqloptlibs', '').split()
embedded_server = (mysqlclient == 'mysqld') embedded_server = (mysqlclient == 'mysqld')
@ -39,15 +39,21 @@ if embedded_server:
name = name + "-embedded" name = name + "-embedded"
version = "1.1.9" version = "1.1.9"
def config(what):
if sys.platform == "win32": if sys.platform == "win32":
try: mysqlroot = os.getenv('mysqlroot', None)
from win32pipe import popen if mysqlroot is None:
except ImportError: print "You need to set the environment variable mysqlroot!"
print "win32pipe is required for building on Windows." print "This should be the path to your MySQL installation."
print "Get it here: http://www.python.org/windows/win32/" print "Probably C:\Program Files\MySQL 4.1\ or something like that."
raise sys.exit(1)
include_dirs = [os.path.join(mysqlroot, "include")]
library_dirs = [os.path.join(mysqlroot, "libs")]
libraries.extend(['zlib', 'msvcrt', 'libcmt', 'wsock32', 'advapi32'])
else: else:
def config(what):
from os import popen from os import popen
return popen("mysql_config --%s" % what).read().strip().split() return popen("mysql_config --%s" % what).read().strip().split()
@ -62,14 +68,7 @@ elif mysqlclient == "mysqld":
library_dirs = [ i[2:] for i in libs if i[:2] == "-L" ] library_dirs = [ i[2:] for i in libs if i[:2] == "-L" ]
libraries = [ i[2:] for i in libs if i[:2] == "-l" ] libraries = [ i[2:] for i in libs if i[:2] == "-l" ]
# For reasons I do not understand, mysql_client --libs includes -lz # Workaround for a pre-4.1.9 bug
# but --libs_r does *not*. This has to be a bug...
# http://bugs.mysql.com/bug.php?id=6273
if sys.platform == "win32":
if "zlib" not in libraries:
libraries.append("zlib")
else:
if "z" not in libraries: if "z" not in libraries:
libraries.append("z") libraries.append("z")