[r381]: branches / branch-1-2 / MySQLdb / setup.py  Maximize  Restore  History

Download this file

162 lines (134 with data), 4.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env python
"""\
=========================
Python interface to MySQL
=========================
MySQLdb is an interface to the popular MySQL_ database server for
Python. The design goals are:
- Compliance with Python database API version 2.0 [PEP-0249]_
- Thread-safety
- Thread-friendliness (threads will not block each other)
MySQL-3.22 through 4.1 and Python-2.3 through 2.4 are currently
supported.
MySQLdb is `Free Software`_.
.. _MySQL: http://www.mysql.com/
.. _`Free Software`: http://www.gnu.org/
.. [PEP-0249] http://www.python.org/peps/pep-0249.html
"""
import os
import sys
from distutils.core import setup
from distutils.extension import Extension
mysqlclient = os.getenv('mysqlclient', 'mysqlclient_r')
mysqlstatic = eval(os.getenv('mysqlstatic', 'False'))
embedded_server = (mysqlclient == 'mysqld')
name = "MySQL-%s" % os.path.basename(sys.executable)
if embedded_server:
name = name + "-embedded"
version = "1.2.0"
extra_objects = []
if sys.platform == "win32":
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 = ['zlib', 'msvcrt', 'libcmt', 'wsock32', 'advapi32']
if mysqlstatic:
extra_objects.append(os.path.join(
library_dirs[0], mysqlclient+'.lib'))
else:
libraries.append(mysqlclient)
else:
def config(what):
from os import popen
f = popen("mysql_config --%s" % what)
data = f.read().strip().split()
if f.close(): data = []
return data
def stripquotes(s):
if s[0] in ("'", '"') and s[0] == s[-1]:
return s[1:-1]
return s
include_dirs = [ i[2:] for i in config('include') if i.startswith('-i') ]
if mysqlclient == "mysqlclient":
libs = config("libs")
elif mysqlclient == "mysqlclient_r":
libs = config("libs_r")
elif mysqlclient == "mysqld":
libs = config("embedded")
library_dirs = [ stripquotes(i[2:]) for i in libs if i.startswith("-L") ]
libraries = [ stripquotes(i[2:]) for i in libs if i.startswith("-l") ]
# Workaround for a pre-4.1.9 bug
if "z" not in libraries:
libraries.append("z")
extra_compile_args = config("cflags")
if mysqlstatic:
extra_objects.append(os.path.join(
library_dirs[0],'lib%s.a' % mysqlclient))
else:
libraries.append(mysqlclient)
# avoid frightening noobs with warnings about missing directories
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) ]
classifiers = """
Development Status :: 5 - Production/Stable
Environment :: Other Environment
License :: OSI Approved :: GNU General Public License (GPL)
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows :: Windows NT/2000
Operating System :: OS Independent
Operating System :: POSIX
Operating System :: POSIX :: Linux
Operating System :: Unix
Programming Language :: C
Programming Language :: Python
Topic :: Database
Topic :: Database :: Database Engines/Servers
"""
metadata = {
'name': name,
'version': version,
'description': "Python interface to MySQL",
'long_description': __doc__,
'author': "Andy Dustman",
'author_email': "andy@dustman.net",
'license': "GPL",
'platforms': "ALL",
'url': "http://sourceforge.net/projects/mysql-python",
'download_url': "http://prdownloads.sourceforge.net/mysql-python/" \
"MySQL-python-%s.tar.gz" % version,
'classifiers': [ c for c in classifiers.split('\n') if c ],
'py_modules': [
"_mysql_exceptions",
"MySQLdb.converters",
"MySQLdb.connections",
"MySQLdb.cursors",
"MySQLdb.sets",
"MySQLdb.times",
"MySQLdb.stringtimes",
"MySQLdb.mxdatetimes",
"MySQLdb.pytimes",
"MySQLdb.constants.CR",
"MySQLdb.constants.FIELD_TYPE",
"MySQLdb.constants.ER",
"MySQLdb.constants.FLAG",
"MySQLdb.constants.REFRESH",
"MySQLdb.constants.CLIENT",
],
'ext_modules': [
Extension(
name='_mysql',
sources=['_mysql.c'],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
extra_objects=extra_objects,
),
],
}
setup(**metadata)

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks