|
1 | 1 | import os |
2 | 2 | import sys |
| 3 | +import textwrap |
3 | 4 | from sysconfig import ( |
4 | 5 | _ALWAYS_STR, |
5 | 6 | _PYTHON_BUILD, |
@@ -209,11 +210,32 @@ def _generate_posix_vars(): |
209 | 210 | os.makedirs(pybuilddir, exist_ok=True) |
210 | 211 | destfile = os.path.join(pybuilddir, name + '.py') |
211 | 212 |
|
| 213 | + replacement = """ |
| 214 | + keys_to_replace = [ |
| 215 | + 'BINDIR', 'BINLIBDEST', 'CONFINCLUDEDIR', |
| 216 | + 'CONFINCLUDEPY', 'DESTDIRS', 'DESTLIB', 'DESTSHARED', |
| 217 | + 'INCLDIRSTOMAKE', 'INCLUDEDIR', 'INCLUDEPY', |
| 218 | + 'LIBDEST', 'LIBDIR', 'LIBPC', 'LIBPL', 'MACHDESTLIB', |
| 219 | + 'MANDIR', 'SCRIPTDIR', 'datarootdir', 'exec_prefix', |
| 220 | + 'TZPATH', 'AR', 'EXENAME', 'LLVM_PROF_MERGER', |
| 221 | + 'VENVLAUNCHERDIR', |
| 222 | + ] |
| 223 | +
|
| 224 | + prefix = build_time_vars['BINDIR'][:-4] |
| 225 | + build_time_vars['prefix'] = sys.base_prefix |
| 226 | +
|
| 227 | + for key in keys_to_replace: |
| 228 | + value = build_time_vars[key] |
| 229 | + build_time_vars[key] = value.replace(prefix, sys.base_prefix) |
| 230 | + """ |
| 231 | + |
212 | 232 | with open(destfile, 'w', encoding='utf8') as f: |
| 233 | + f.write('import sys\n') |
213 | 234 | f.write('# system configuration generated and used by' |
214 | 235 | ' the sysconfig module\n') |
215 | 236 | f.write('build_time_vars = ') |
216 | 237 | _print_config_dict(vars, stream=f) |
| 238 | + f.write('\n%s' % textwrap.dedent(replacement)) |
217 | 239 |
|
218 | 240 | # Create file used for sys.path fixup -- see Modules/getpath.c |
219 | 241 | with open('pybuilddir.txt', 'w', encoding='utf8') as f: |
|
0 commit comments