@@ -27,6 +27,21 @@ def mysql_config(what):
27
27
return data
28
28
mysql_config .path = "mysql_config"
29
29
30
+
31
+ def _find_client_from_libs (libs ):
32
+ for lib in libs :
33
+ if lib .startswith ('-l' ) and lib .endswith ('client' ):
34
+ return lib [2 :]
35
+
36
+
37
+ def _find_static_lib (library_dirs , libname ):
38
+ for lib_dir in library_dirs :
39
+ full_path = os .path .join (lib_dir , libname )
40
+ if os .path .exists (full_path ):
41
+ return full_path
42
+ return full_path
43
+
44
+
30
45
def get_config ():
31
46
from setup_common import get_metadata_and_options , enabled , create_release_file
32
47
@@ -40,17 +55,16 @@ def get_config():
40
55
if enabled (options , 'embedded' ):
41
56
libs = mysql_config ("libmysqld-libs" )
42
57
client = "mysqld"
43
- elif enabled (options , 'threadsafe' ):
44
- libs = mysql_config ("libs_r" )
45
- client = "mysqlclient_r"
58
+ else :
59
+ libs = None
60
+ if enabled (options , 'threadsafe' ):
61
+ libs = mysql_config ("libs_r" )
46
62
if not libs :
47
63
libs = mysql_config ("libs" )
48
- client = "mysqlclient"
49
- else :
50
- libs = mysql_config ("libs" )
51
- client = "mysqlclient"
64
+ client = _find_client_from_libs (libs )
52
65
53
66
library_dirs = [dequote (i [2 :]) for i in libs if i .startswith ('-L' )]
67
+ library_dirs .append (library_dirs [0 ] + "/mysql" )
54
68
libraries = [dequote (i [2 :]) for i in libs if i .startswith ('-l' )]
55
69
extra_link_args = [x for x in libs if not x .startswith (('-l' , '-L' ))]
56
70
@@ -67,7 +81,8 @@ def get_config():
67
81
for i in mysql_config ('include' ) if i .startswith ('-I' )]
68
82
69
83
if static :
70
- extra_objects .append (os .path .join (library_dirs [0 ], 'lib%s.a' % client ))
84
+ extra_objects .append (
85
+ _find_static_lib (library_dirs , 'lib%s.a' % client ))
71
86
if client in libraries :
72
87
libraries .remove (client )
73
88
0 commit comments