Without this patch the value of sysconfig.get_config_var('LDSHARED')

is wrong when PY_LDFLAGS is not empty.

The bug was caused by LDSHARED getting expanded *before* sysconfig
renamed PY_LDSHARED (and simular values) to names without a PY_
prefix.

The patch tries to maintain the intended behaviour of allowing users
to set LDFLAGS in the environment and have that affect the build.

Without this patch a universal build on OSX cannot build universal
(fat binary) extensions.
This commit is contained in:
Ronald Oussoren 2010-07-20 16:07:10 +00:00
parent 41e6c3df8b
commit d21886cea4
1 changed files with 27 additions and 7 deletions

View File

@ -225,6 +225,12 @@ def _parse_makefile(filename, vars=None):
# do variable interpolation here # do variable interpolation here
variables = list(notdone.keys()) variables = list(notdone.keys())
# Variables with a 'PY_' prefix in the makefile. These need to
# be made available without that prefix through sysconfig.
# Special care is needed to ensure that variable expansion works, even
# if the expansion uses the name without a prefix.
renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS')
while len(variables) > 0: while len(variables) > 0:
for name in tuple(variables): for name in tuple(variables):
value = notdone[name] value = notdone[name]
@ -240,8 +246,20 @@ def _parse_makefile(filename, vars=None):
elif n in os.environ: elif n in os.environ:
# do it like make: fall back to environment # do it like make: fall back to environment
item = os.environ[n] item = os.environ[n]
elif n in renamed_variables:
if name.startswith('PY_') and name[3:] in renamed_variables:
item = ""
elif 'PY_' + n in notdone:
found = False
else:
item = str(done['PY_' + n])
else: else:
done[n] = item = "" done[n] = item = ""
if found: if found:
after = value[m.end():] after = value[m.end():]
value = value[:m.start()] + item + after value = value[:m.start()] + item + after
@ -255,17 +273,19 @@ def _parse_makefile(filename, vars=None):
else: else:
done[name] = value done[name] = value
variables.remove(name) variables.remove(name)
if name.startswith('PY_') \
and name[3:] in renamed_variables:
name = name[3:]
if name not in done:
done[name] = value
else: else:
# bogus variable reference; just drop it since we can't deal # bogus variable reference; just drop it since we can't deal
variables.remove(name) variables.remove(name)
# Add in CFLAGS, LDFLAGS, and CPPFLAGS, which are named with a
# prefix in the Makefile.
for var in ('CFLAGS', 'LDFLAGS', 'CPPFLAGS'):
makefile_value = done.get('PY_' + var)
if makefile_value is not None:
done[var] = makefile_value
# save the results in the global dictionary # save the results in the global dictionary
vars.update(done) vars.update(done)
return vars return vars