diff -Naur Python-3.5.2-orig/Lib/sysconfig.py Python-3.5.2/Lib/sysconfig.py --- Python-3.5.2-orig/Lib/sysconfig.py 2016-06-26 00:38:36.000000000 +0300 +++ Python-3.5.2/Lib/sysconfig.py 2016-07-12 14:20:28.876300700 +0300 @@ -257,6 +257,7 @@ # if the expansion uses the name without a prefix. renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS') + done['prefix']='${SYS_PREFIX}' while len(variables) > 0: for name in tuple(variables): value = notdone[name] @@ -398,6 +399,19 @@ f.write('build_time_vars = ') pprint.pprint(vars, stream=f) + # Now reload the file and replace: + replacements = {": '${SYS_PREFIX}'" : ": sys.prefix", + ": '${SYS_PREFIX}" : ": sys.prefix + '", + "${SYS_PREFIX}'" : "' + sys.prefix", + "${SYS_PREFIX}" : "' + sys.prefix + '"} + + contents = open(destfile).read() + for rep in replacements.keys(): + contents = contents.replace(rep, replacements[rep]) + with open(destfile, 'w', encoding='utf8') as f: + f.write('import sys\n') + f.write(contents) + # Create file used for sys.path fixup -- see Modules/getpath.c with open('pybuilddir.txt', 'w', encoding='ascii') as f: f.write(pybuilddir)