diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2010-07-20 16:07:10 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2010-07-20 16:07:10 (GMT) |
commit | d21886cea4d661ba81b577d4bb0792e4ce0e575a (patch) | |
tree | e1ee1d26b2a18b52d6bf809fd22e8e982356c85a /Lib/sysconfig.py | |
parent | 41e6c3df8bd8e7f3990886c5269b2f446095de38 (diff) | |
download | cpython-d21886cea4d661ba81b577d4bb0792e4ce0e575a.zip cpython-d21886cea4d661ba81b577d4bb0792e4ce0e575a.tar.gz cpython-d21886cea4d661ba81b577d4bb0792e4ce0e575a.tar.bz2 |
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.
Diffstat (limited to 'Lib/sysconfig.py')
-rw-r--r-- | Lib/sysconfig.py | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py index 28731df..2fec910 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -225,6 +225,12 @@ def _parse_makefile(filename, vars=None): # do variable interpolation here 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: for name in tuple(variables): value = notdone[name] @@ -240,8 +246,20 @@ def _parse_makefile(filename, vars=None): elif n in os.environ: # do it like make: fall back to environment 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: done[n] = item = "" + if found: after = value[m.end():] value = value[:m.start()] + item + after @@ -255,17 +273,19 @@ def _parse_makefile(filename, vars=None): else: done[name] = value 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: # bogus variable reference; just drop it since we can't deal 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 vars.update(done) return vars |