1
1
# MySQL Connector/Python - MySQL driver written in Python.
2
- # Copyright (c) 2014, 2015 , Oracle and/or its affiliates. All rights reserved.
2
+ # Copyright (c) 2014, 2017 , Oracle and/or its affiliates. All rights reserved.
3
3
4
4
# MySQL Connector/Python is licensed under the terms of the GPLv2
5
5
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -136,21 +136,7 @@ def unix_lib_is64bit(lib_file):
136
136
return False
137
137
138
138
139
- def get_mysql_config_info (mysql_config ):
140
- """Get MySQL information using mysql_config tool
141
-
142
- Returns a dict.
143
- """
144
- options = ['cflags' , 'include' , 'libs' , 'libs_r' , 'plugindir' , 'version' ]
145
-
146
- cmd = [mysql_config ] + [ "--{0}" .format (opt ) for opt in options ]
147
-
148
- try :
149
- proc = Popen (cmd , stdout = PIPE , universal_newlines = True )
150
- stdout , _ = proc .communicate ()
151
- except OSError as exc :
152
- raise DistutilsExecError ("Failed executing mysql_config: {0}" .format (
153
- str (exc )))
139
+ def parse_mysql_config_info (options , stdout ):
154
140
log .debug ("# stdout: {0}" .format (stdout ))
155
141
info = {}
156
142
for option , line in zip (options , stdout .split ('\n ' )):
@@ -173,7 +159,28 @@ def get_mysql_config_info(mysql_config):
173
159
info ['lib_r_dir' ] = libs [0 ].replace ('-L' , '' )
174
160
info ['libs_r' ] = [ lib .replace ('-l' , '' ) for lib in libs [1 :] ]
175
161
176
- info ['include' ] = info ['include' ].replace ('-I' , '' )
162
+ info ['include' ] = [x .strip () for x in info ['include' ].split ('-I' )[1 :]]
163
+
164
+ return info
165
+
166
+
167
+ def get_mysql_config_info (mysql_config ):
168
+ """Get MySQL information using mysql_config tool
169
+
170
+ Returns a dict.
171
+ """
172
+ options = ['cflags' , 'include' , 'libs' , 'libs_r' , 'plugindir' , 'version' ]
173
+
174
+ cmd = [mysql_config ] + [ "--{0}" .format (opt ) for opt in options ]
175
+
176
+ try :
177
+ proc = Popen (cmd , stdout = PIPE , universal_newlines = True )
178
+ stdout , _ = proc .communicate ()
179
+ except OSError as exc :
180
+ raise DistutilsExecError ("Failed executing mysql_config: {0}" .format (
181
+ str (exc )))
182
+
183
+ info = parse_mysql_config_info (options , stdout )
177
184
178
185
# Try to figure out the architecture
179
186
info ['arch' ] = None
@@ -316,7 +323,7 @@ def _finalize_connector_c(self, connc_loc):
316
323
else :
317
324
raise OSError ("Unsupported platform: %s" % os .name )
318
325
319
- include_dir = os .path .join (connc_loc , 'include' )
326
+ include_dirs = [ os .path .join (connc_loc , 'include' )]
320
327
if os .name == 'nt' :
321
328
libraries = ['libmysql' ]
322
329
else :
@@ -341,19 +348,20 @@ def _finalize_connector_c(self, connc_loc):
341
348
log .error (err_version )
342
349
sys .exit (1 )
343
350
344
- include_dir = myc_info ['include' ]
351
+ include_dirs = myc_info ['include' ]
345
352
libraries = myc_info ['libs' ]
346
353
library_dirs = myc_info ['lib_dir' ]
347
354
self ._mysql_config_info = myc_info
348
355
self .arch = self ._mysql_config_info ['arch' ]
349
356
connc_64bit = self .arch == 'x86_64'
350
357
351
- if not os .path .exists (include_dir ):
352
- log .error (err_invalid_loc , connc_loc )
353
- sys .exit (1 )
358
+ for include_dir in include_dirs :
359
+ if not os .path .exists (include_dir ):
360
+ log .error (err_invalid_loc , connc_loc )
361
+ sys .exit (1 )
354
362
355
363
# Set up the build_ext class
356
- self .include_dirs .append ( include_dir )
364
+ self .include_dirs .extend ( include_dirs )
357
365
self .libraries .extend (libraries )
358
366
self .library_dirs .append (library_dirs )
359
367
0 commit comments