diff options
author | Ned Deily <nad@acm.org> | 2013-08-01 22:39:47 (GMT) |
---|---|---|
committer | Ned Deily <nad@acm.org> | 2013-08-01 22:39:47 (GMT) |
commit | 362532bc48f868b24162e32987dad307b2090060 (patch) | |
tree | faf111c6727bcf30cd715979d16949b8ed17bd59 /Mac | |
parent | 284e5ce67ec0ffcc3feb5d8526727fa3a8c35f7a (diff) | |
download | cpython-362532bc48f868b24162e32987dad307b2090060.zip cpython-362532bc48f868b24162e32987dad307b2090060.tar.gz cpython-362532bc48f868b24162e32987dad307b2090060.tar.bz2 |
Fix OS X installer build script to handle the pretty-printed _sysconfigdata.py
when removing references to temporary build files. This is not an elegant
solution but it does isolate changes to just build-installer.py.
Diffstat (limited to 'Mac')
-rwxr-xr-x | Mac/BuildScript/build-installer.py | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py index 004765a..64c6171 100755 --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -982,22 +982,62 @@ def buildPython(): # the end-users system. Also remove the directories from _sysconfigdata.py # (added in 3.3) if it exists. + include_path = '-I%s/libraries/usr/local/include' % (WORKDIR,) + lib_path = '-L%s/libraries/usr/local/lib' % (WORKDIR,) + path_to_lib = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', 'Versions', version, 'lib', 'python%s'%(version,)) - paths = [os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile'), - os.path.join(path_to_lib, '_sysconfigdata.py')] - for path in paths: - if not os.path.exists(path): - continue + + # fix Makefile + path = os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile') + fp = open(path, 'r') + data = fp.read() + fp.close() + + for p in (include_path, lib_path): + data = data.replace(" " + p, '') + data = data.replace(p + " ", '') + + fp = open(path, 'w') + fp.write(data) + fp.close() + + # fix _sysconfigdata if it exists + # + # TODO: make this more robust! test_sysconfig_module of + # distutils.tests.test_sysconfig.SysconfigTestCase tests that + # the output from get_config_var in both sysconfig and + # distutils.sysconfig is exactly the same for both CFLAGS and + # LDFLAGS. The fixing up is now complicated by the pretty + # printing in _sysconfigdata.py. Also, we are using the + # pprint from the Python running the installer build which + # may not cosmetically format the same as the pprint in the Python + # being built (and which is used to originally generate + # _sysconfigdata.py). + + import pprint + path = os.path.join(path_to_lib, '_sysconfigdata.py') + if os.path.exists(path): fp = open(path, 'r') data = fp.read() fp.close() + # create build_time_vars dict + exec(data) + vars = {} + for k, v in build_time_vars.items(): + if type(v) == type(''): + for p in (include_path, lib_path): + v = v.replace(' ' + p, '') + v = v.replace(p + ' ', '') + vars[k] = v - data = data.replace(' -L%s/libraries/usr/local/lib'%(WORKDIR,), '') - data = data.replace(' -I%s/libraries/usr/local/include'%(WORKDIR,), '') fp = open(path, 'w') - fp.write(data) + # duplicated from sysconfig._generate_posix_vars() + fp.write('# system configuration generated and used by' + ' the sysconfig module\n') + fp.write('build_time_vars = ') + pprint.pprint(vars, stream=fp) fp.close() # Add symlinks in /usr/local/bin, using relative links |