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.extension import Extension
mysqlclient = os.getenv('mysqlclient', 'mysqlclient')
mysqlclient = os.getenv('mysqlclient', 'mysqlclient_r')
mysqloptlibs = os.getenv('mysqloptlibs', '').split()
embedded_server = (mysqlclient == 'mysqld')
@ -39,15 +39,21 @@ if embedded_server:
name = name + "-embedded"
version = "1.1.9"
def config(what):
if sys.platform == "win32":
try:
from win32pipe import popen
except ImportError:
print "win32pipe is required for building on Windows."
print "Get it here: http://www.python.org/windows/win32/"
raise
mysqlroot = os.getenv('mysqlroot', None)
if mysqlroot is None:
print "You need to set the environment variable mysqlroot!"
print "This should be the path to your MySQL installation."
print "Probably C:\Program Files\MySQL 4.1\ or something like that."
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:
def config(what):
from os import popen
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" ]
libraries = [ i[2:] for i in libs if i[:2] == "-l" ]
# For reasons I do not understand, mysql_client --libs includes -lz
# 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:
# Workaround for a pre-4.1.9 bug
if "z" not in libraries:
libraries.append("z")