Skip to content

Commit a4f6b00

Browse files
committed
Sync 2.7.x, 3.3.x, and 3.4.x versions of OS X build-installer.py.
1 parent 4b7a023 commit a4f6b00

File tree

1 file changed

+48
-8
lines changed

1 file changed

+48
-8
lines changed

Mac/BuildScript/build-installer.py

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,22 +1058,62 @@ def buildPython():
10581058
# the end-users system. Also remove the directories from _sysconfigdata.py
10591059
# (added in 3.3) if it exists.
10601060

1061+
include_path = '-I%s/libraries/usr/local/include' % (WORKDIR,)
1062+
lib_path = '-L%s/libraries/usr/local/lib' % (WORKDIR,)
1063+
10611064
path_to_lib = os.path.join(rootDir, 'Library', 'Frameworks',
10621065
'Python.framework', 'Versions',
10631066
version, 'lib', 'python%s'%(version,))
1064-
paths = [os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile'),
1065-
os.path.join(path_to_lib, '_sysconfigdata.py')]
1066-
for path in paths:
1067-
if not os.path.exists(path):
1068-
continue
1067+
1068+
# fix Makefile
1069+
path = os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile')
1070+
fp = open(path, 'r')
1071+
data = fp.read()
1072+
fp.close()
1073+
1074+
for p in (include_path, lib_path):
1075+
data = data.replace(" " + p, '')
1076+
data = data.replace(p + " ", '')
1077+
1078+
fp = open(path, 'w')
1079+
fp.write(data)
1080+
fp.close()
1081+
1082+
# fix _sysconfigdata if it exists
1083+
#
1084+
# TODO: make this more robust! test_sysconfig_module of
1085+
# distutils.tests.test_sysconfig.SysconfigTestCase tests that
1086+
# the output from get_config_var in both sysconfig and
1087+
# distutils.sysconfig is exactly the same for both CFLAGS and
1088+
# LDFLAGS. The fixing up is now complicated by the pretty
1089+
# printing in _sysconfigdata.py. Also, we are using the
1090+
# pprint from the Python running the installer build which
1091+
# may not cosmetically format the same as the pprint in the Python
1092+
# being built (and which is used to originally generate
1093+
# _sysconfigdata.py).
1094+
1095+
import pprint
1096+
path = os.path.join(path_to_lib, '_sysconfigdata.py')
1097+
if os.path.exists(path):
10691098
fp = open(path, 'r')
10701099
data = fp.read()
10711100
fp.close()
1101+
# create build_time_vars dict
1102+
exec(data)
1103+
vars = {}
1104+
for k, v in build_time_vars.items():
1105+
if type(v) == type(''):
1106+
for p in (include_path, lib_path):
1107+
v = v.replace(' ' + p, '')
1108+
v = v.replace(p + ' ', '')
1109+
vars[k] = v
10721110

1073-
data = data.replace(' -L%s/libraries/usr/local/lib'%(WORKDIR,), '')
1074-
data = data.replace(' -I%s/libraries/usr/local/include'%(WORKDIR,), '')
10751111
fp = open(path, 'w')
1076-
fp.write(data)
1112+
# duplicated from sysconfig._generate_posix_vars()
1113+
fp.write('# system configuration generated and used by'
1114+
' the sysconfig module\n')
1115+
fp.write('build_time_vars = ')
1116+
pprint.pprint(vars, stream=fp)
10771117
fp.close()
10781118

10791119
# Add symlinks in /usr/local/bin, using relative links

0 commit comments

Comments
 (0)