Skip to content

Commit 0d3f364

Browse files
committed
Pass ldflags to extra_link_args
mysql_config may produce link args other than -L and -l.
1 parent 072a6cd commit 0d3f364

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

setup_posix.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ def dequote(s):
1313
s = s[1:-1]
1414
return s
1515

16-
def compiler_flag(f):
17-
return "-%s" % f
18-
1916
def mysql_config(what):
2017
from os import popen
2118

@@ -53,29 +50,24 @@ def get_config():
5350
libs = mysql_config("libs")
5451
client = "mysqlclient"
5552

56-
library_dirs = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("L")) ]
57-
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
53+
library_dirs = [dequote(i[2:]) for i in libs if i.startswith('-L')]
54+
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
55+
extra_link_args = [x for x in libs if not x.startswith(('-l', '-L'))]
5856

59-
removable_compile_args = [ compiler_flag(f) for f in "ILl" ]
60-
extra_compile_args = [ i.replace("%", "%%") for i in mysql_config("cflags")
61-
if i[:2] not in removable_compile_args ]
57+
removable_compile_args = ('-I', '-L', '-l')
58+
extra_compile_args = [i.replace("%", "%%") for i in mysql_config("cflags")
59+
if i[:2] not in removable_compile_args]
6260

6361
# Copy the arch flags for linking as well
64-
extra_link_args = list()
6562
for i in range(len(extra_compile_args)):
6663
if extra_compile_args[i] == '-arch':
6764
extra_link_args += ['-arch', extra_compile_args[i + 1]]
6865

69-
include_dirs = [ dequote(i[2:])
70-
for i in mysql_config('include')
71-
if i.startswith(compiler_flag('I')) ]
72-
if not include_dirs: # fix for MySQL-3.23
73-
include_dirs = [ dequote(i[2:])
74-
for i in mysql_config('cflags')
75-
if i.startswith(compiler_flag('I')) ]
66+
include_dirs = [dequote(i[2:])
67+
for i in mysql_config('include') if i.startswith('-I')]
7668

7769
if static:
78-
extra_objects.append(os.path.join(library_dirs[0],'lib%s.a' % client))
70+
extra_objects.append(os.path.join(library_dirs[0], 'lib%s.a' % client))
7971
if client in libraries:
8072
libraries.remove(client)
8173

@@ -104,4 +96,3 @@ def get_config():
10496

10597
if __name__ == "__main__":
10698
sys.stderr.write("""You shouldn't be running this directly; it is used by setup.py.""")
107-

0 commit comments

Comments
 (0)