Should now auto-detect all build settings for any platform.

win32 now requires win32pipe to build. Build has only been
tested on Linux, but AFAIK, os.popen() works properly on
all other platforms, and certainly must work on anything
remotely POSIX/UNIX-like. I am assuming that it will work
on Mac OS X as well.
This commit is contained in:
adustman
2005-01-15 02:16:26 +00:00
parent f0d497d8f3
commit 249ab4d23e

View File

@ -39,71 +39,47 @@ if embedded_server:
name = name + "-embedded" name = name + "-embedded"
version = "1.1.8" version = "1.1.8"
# include files and library locations should cover most platforms def config(what):
include_dirs = [ if sys.platform == "win32":
'/usr/local/include/mysql', try:
'/usr/local/mysql/include', from win32pipe import popen
'/usr/local/mysql/include/mysql', except ImportError:
'/usr/include/mysql', print "win32pipe is required for building on Windows."
] print "Get it here: http://www.python.org/windows/win32/"
library_dirs = [ raise
'/usr/local/lib/mysql', else:
'/usr/local/mysql/lib', from os import popen
'/usr/local/mysql/lib/mysql', return popen("mysql_config --%s" % what).read().strip().split()
'/usr/lib/mysql',
]
libraries = [mysqlclient] + mysqloptlibs include_dirs = [ i[2:] for i in config('include') ]
# On some platorms, this can be used to find the shared libraries if mysqlclient == "mysqlclient":
# at runtime, if they are in a non-standard location. Doesn't libs = config("libs")
# work for Linux gcc. elif mysqlclient == "mysqlclient_r":
runtime_library_dirs = [] libs = config("libs_r")
elif mysqlclient == "mysqld":
libs = config("embedded")
library_dirs = [ i[2:] for i in libs if i[:2] == "-L" ]
libraries = [ i[2:] for i in libs if i[:2] == "-l" ]
# This can be used to force linking against static libraries. # For reasons I do not understand, mysql_client --libs includes -lz
extra_objects = [] # but --libs_r does *not*. This has to be a bug...
# http://bugs.mysql.com/bug.php?id=6273
# Sometimes the compiler or linker needs an extra switch to make if sys.platform == "win32":
# things work. if "zlib" not in libraries:
extra_compile_args = [] libraries.append("zlib")
extra_link_args = []
if sys.platform == "netbsd1":
include_dirs = ['/usr/pkg/include/mysql']
library_dirs = ['/usr/pkg/lib/mysql']
elif sys.platform in ("freebsd4", "openbsd3"):
LOCALBASE = os.getenv('LOCALBASE', '/usr/local')
include_dirs = ['%s/include/mysql' % LOCALBASE]
library_dirs = ['%s/lib/mysql' % LOCALBASE]
elif sys.platform == "sunos5": # Solaris 2.8 + gcc
runtime_library_dirs.append('/usr/local/lib:/usr/openwin/lib:/usr/dt/lib')
extra_compile_args.append("-fPIC")
elif sys.platform == "win32": # Ugh
include_dirs = [r'c:\mysql\include']
library_dirs = [r'c:\mysql\lib\opt']
libraries.extend(['zlib', 'msvcrt', 'libcmt', 'wsock32', 'advapi32'])
extra_objects = [r'c:\mysql\lib\opt\mysqlclient.lib']
elif sys.platform == "cygwin":
include_dirs = ['/c/mysql/include']
library_dirs = ['/c/mysql/lib']
extra_compile_args.append('-DMS_WIN32')
elif sys.platform[:6] == "darwin": # Mac OS X
include_dirs.append('/sw/include/mysql')
library_dirs.append('/sw/lib/mysql')
extra_link_args.append('-flat_namespace')
elif sys.platform == 'linux2' and os.getenv('HOSTTYPE') == 'alpha':
libraries.extend(['ots', 'cpml'])
elif os.name == "posix": # UNIX-ish platforms not covered above
pass # default should work
else: else:
raise "UnknownPlatform", "sys.platform=%s, os.name=%s" % \ if "z" not in libraries:
(sys.platform, os.name) libraries.append("z")
extra_compile_args = config("cflags")
# avoid frightening noobs with warnings about missing directories # avoid frightening noobs with warnings about missing directories
include_dirs = [ d for d in include_dirs if os.path.isdir(d) ] include_dirs = [ d for d in include_dirs if os.path.isdir(d) ]
library_dirs = [ d for d in library_dirs if os.path.isdir(d) ] library_dirs = [ d for d in library_dirs if os.path.isdir(d) ]
classifiers = """\ classifiers = """
Development Status :: 5 - Production/Stable Development Status :: 5 - Production/Stable
Environment :: Other Environment Environment :: Other Environment
License :: OSI Approved :: GNU General Public License (GPL) License :: OSI Approved :: GNU General Public License (GPL)
@ -116,7 +92,8 @@ Operating System :: Unix
Programming Language :: C Programming Language :: C
Programming Language :: Python Programming Language :: Python
Topic :: Database Topic :: Database
Topic :: Database :: Database Engines/Servers""".split('\n') Topic :: Database :: Database Engines/Servers
"""
metadata = { metadata = {
'name': name, 'name': name,
@ -130,7 +107,7 @@ metadata = {
'url': "http://sourceforge.net/projects/mysql-python", 'url': "http://sourceforge.net/projects/mysql-python",
'download_url': "http://prdownloads.sourceforge.net/mysql-python/" \ 'download_url': "http://prdownloads.sourceforge.net/mysql-python/" \
"MySQL-python-%s.tar.gz" % version, "MySQL-python-%s.tar.gz" % version,
'classifiers': classifiers, 'classifiers': [ c for c in classifiers.split('\n') if c ],
'py_modules': [ 'py_modules': [
"_mysql_exceptions", "_mysql_exceptions",
"MySQLdb.converters", "MySQLdb.converters",
@ -154,10 +131,7 @@ metadata = {
sources=['_mysql.c'], sources=['_mysql.c'],
include_dirs=include_dirs, include_dirs=include_dirs,
library_dirs=library_dirs, library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
libraries=libraries, libraries=libraries,
extra_objects=extra_objects,
extra_link_args=extra_link_args,
extra_compile_args=extra_compile_args, extra_compile_args=extra_compile_args,
), ),
], ],