Mercurial > p > mysql-python > mysqldb-2
annotate setup_posix.py @ 60:c9fd1a7932f4 MySQLdb
Merge back change 609 for remaining old style exceptions
author | kylev |
---|---|
date | Thu, 05 Mar 2009 20:00:51 +0000 |
parents | 6732437eb2ac |
children | 6cc22ee607da |
rev | line source |
---|---|
58 | 1 import os |
2 import sys | |
5 | 3 |
4 def dequote(s): | |
58 | 5 """This dequote() business is required for some older versions of |
6 mysql_config. | |
7 """ | |
5 | 8 if s[0] in "\"'" and s[0] == s[-1]: |
9 s = s[1:-1] | |
10 return s | |
11 | |
12 def compiler_flag(f): | |
13 return "-%s" % f | |
14 | |
15 def mysql_config(what): | |
58 | 16 f = os.popen("%s --%s" % (mysql_config.path, what)) |
5 | 17 data = f.read().strip().split() |
18 ret = f.close() | |
19 if ret: | |
20 if ret/256: | |
21 data = [] | |
22 if ret/256 > 1: | |
60
c9fd1a7932f4
Merge back change 609 for remaining old style exceptions
kylev
parents:
58
diff
changeset
|
23 raise EnvironmentError("%s not found" % (mysql_config.path,)) |
5 | 24 return data |
9
0e37ee00beb7
Merge changes from 1.2 branch (r470:483): Mostly build-related.
adustman
parents:
8
diff
changeset
|
25 mysql_config.path = "mysql_config" |
5 | 26 |
27 def get_config(): | |
28 from setup_common import get_metadata_and_options, enabled, create_release_file | |
29 | |
30 metadata, options = get_metadata_and_options() | |
31 | |
9
0e37ee00beb7
Merge changes from 1.2 branch (r470:483): Mostly build-related.
adustman
parents:
8
diff
changeset
|
32 if 'mysql_config' in options: |
0e37ee00beb7
Merge changes from 1.2 branch (r470:483): Mostly build-related.
adustman
parents:
8
diff
changeset
|
33 mysql_config.path = options['mysql_config'] |
58 | 34 |
5 | 35 extra_objects = [] |
36 static = enabled(options, 'static') | |
37 if enabled(options, 'embedded'): | |
38 libs = mysql_config("libmysqld-libs") | |
39 client = "mysqld" | |
40 elif enabled(options, 'threadsafe'): | |
41 libs = mysql_config("libs_r") | |
42 client = "mysqlclient_r" | |
43 if not libs: | |
44 libs = mysql_config("libs") | |
45 client = "mysqlclient" | |
46 else: | |
47 libs = mysql_config("libs") | |
48 client = "mysqlclient" | |
49 | |
50 library_dirs = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("L")) ] | |
51 libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ] | |
58 | 52 |
5 | 53 removable_compile_args = [ compiler_flag(f) for f in "ILl" ] |
8
fa8974a41c76
New error handling code, plus some small fixes from 1.2
adustman
parents:
5
diff
changeset
|
54 extra_compile_args = [ i.replace("%", "%%") for i in mysql_config("cflags") |
5 | 55 if i[:2] not in removable_compile_args ] |
56 include_dirs = [ dequote(i[2:]) | |
57 for i in mysql_config('include') | |
58 if i.startswith(compiler_flag('I')) ] | |
59 if not include_dirs: # fix for MySQL-3.23 | |
60 include_dirs = [ dequote(i[2:]) | |
61 for i in mysql_config('cflags') | |
62 if i.startswith(compiler_flag('I')) ] | |
58 | 63 |
5 | 64 if static: |
65 extra_objects.append(os.path.join( | |
66 library_dirs[0],'lib%s.a' % client)) | |
58 | 67 |
17
7c7a89123d65
egg names already include python versoin, so don't add it to package name.
adustman
parents:
9
diff
changeset
|
68 name = "MySQL-python" |
5 | 69 if enabled(options, 'embedded'): |
70 name = name + "-embedded" | |
71 metadata['name'] = name | |
58 | 72 |
5 | 73 define_macros = [ |
74 ('version_info', metadata['version_info']), | |
75 ('__version__', metadata['version']), | |
76 ] | |
77 create_release_file(metadata) | |
78 del metadata['version_info'] | |
79 ext_options = dict( | |
80 name = "_mysql", | |
81 library_dirs = library_dirs, | |
82 libraries = libraries, | |
83 extra_compile_args = extra_compile_args, | |
84 include_dirs = include_dirs, | |
85 extra_objects = extra_objects, | |
86 define_macros = define_macros, | |
87 ) | |
88 return metadata, ext_options | |
89 | |
90 if __name__ == "__main__": | |
91 print """You shouldn't be running this directly; it is used by setup.py.""" |