@@ -152,21 +152,7 @@ def unix_lib_is64bit(lib_file):
152
152
return False
153
153
154
154
155
- def get_mysql_config_info (mysql_config ):
156
- """Get MySQL information using mysql_config tool
157
-
158
- Returns a dict.
159
- """
160
- options = ['cflags' , 'include' , 'libs' , 'libs_r' , 'plugindir' , 'version' ]
161
-
162
- cmd = [mysql_config ] + [ "--{0}" .format (opt ) for opt in options ]
163
-
164
- try :
165
- proc = Popen (cmd , stdout = PIPE , universal_newlines = True )
166
- stdout , _ = proc .communicate ()
167
- except OSError as exc :
168
- raise DistutilsExecError ("Failed executing mysql_config: {0}" .format (
169
- str (exc )))
155
+ def parse_mysql_config_info (options , stdout ):
170
156
log .debug ("# stdout: {0}" .format (stdout ))
171
157
info = {}
172
158
for option , line in zip (options , stdout .split ('\n ' )):
@@ -192,7 +178,28 @@ def get_mysql_config_info(mysql_config):
192
178
info ['lib_r_dir' ] = libs [0 ].replace ('-L' , '' )
193
179
info ['libs_r' ] = [ lib .replace ('-l' , '' ) for lib in libs [1 :] ]
194
180
195
- info ['include' ] = info ['include' ].replace ('-I' , '' )
181
+ info ['include' ] = [x .strip () for x in info ['include' ].split ('-I' )[1 :]]
182
+
183
+ return info
184
+
185
+
186
+ def get_mysql_config_info (mysql_config ):
187
+ """Get MySQL information using mysql_config tool
188
+
189
+ Returns a dict.
190
+ """
191
+ options = ['cflags' , 'include' , 'libs' , 'libs_r' , 'plugindir' , 'version' ]
192
+
193
+ cmd = [mysql_config ] + [ "--{0}" .format (opt ) for opt in options ]
194
+
195
+ try :
196
+ proc = Popen (cmd , stdout = PIPE , universal_newlines = True )
197
+ stdout , _ = proc .communicate ()
198
+ except OSError as exc :
199
+ raise DistutilsExecError ("Failed executing mysql_config: {0}" .format (
200
+ str (exc )))
201
+
202
+ info = parse_mysql_config_info (options , stdout )
196
203
197
204
# Try to figure out the architecture
198
205
info ['arch' ] = None
@@ -355,7 +362,7 @@ def _finalize_connector_c(self, connc_loc):
355
362
else :
356
363
raise OSError ("Unsupported platform: %s" % os .name )
357
364
358
- include_dir = os .path .join (connc_loc , 'include' )
365
+ include_dirs = [ os .path .join (connc_loc , 'include' )]
359
366
if os .name == 'nt' :
360
367
libraries = ['libmysql' ]
361
368
else :
@@ -380,19 +387,20 @@ def _finalize_connector_c(self, connc_loc):
380
387
log .error (err_version )
381
388
sys .exit (1 )
382
389
383
- include_dir = myc_info ['include' ]
390
+ include_dirs = myc_info ['include' ]
384
391
libraries = myc_info ['libs' ]
385
392
library_dirs = myc_info ['lib_dir' ]
386
393
self ._mysql_config_info = myc_info
387
394
self .arch = self ._mysql_config_info ['arch' ]
388
395
connc_64bit = self .arch == 'x86_64'
389
396
390
- if not os .path .exists (include_dir ):
391
- log .error (err_invalid_loc , connc_loc )
392
- sys .exit (1 )
397
+ for include_dir in include_dirs :
398
+ if not os .path .exists (include_dir ):
399
+ log .error (err_invalid_loc , connc_loc )
400
+ sys .exit (1 )
393
401
394
402
# Set up the build_ext class
395
- self .include_dirs .append ( include_dir )
403
+ self .include_dirs .extend ( include_dirs )
396
404
self .libraries .extend (libraries )
397
405
self .library_dirs .append (library_dirs )
398
406
0 commit comments