diff options
author | Trent Nelson <trent@trent.me> | 2012-10-17 08:24:44 (GMT) |
---|---|---|
committer | Trent Nelson <trent@trent.me> | 2012-10-17 08:24:44 (GMT) |
commit | b21099a4ca3bc680cc8e257cf8f2684412671275 (patch) | |
tree | 0b818b1a2f639b00f02adf9a8b266e77efe8e442 /Lib/sysconfig.py | |
parent | 42da889fec6298debe216abac36dce9b87ed746d (diff) | |
parent | ee528cccde02a5b0382e47a709f8a8311415dad1 (diff) | |
download | cpython-b21099a4ca3bc680cc8e257cf8f2684412671275.zip cpython-b21099a4ca3bc680cc8e257cf8f2684412671275.tar.gz cpython-b21099a4ca3bc680cc8e257cf8f2684412671275.tar.bz2 |
Merge issue #15298: fix an OS X bootstrap issue with _sysconfigdata.py.
Diffstat (limited to 'Lib/sysconfig.py')
-rw-r--r-- | Lib/sysconfig.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py index d2870a7..cf6b2db 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -371,18 +371,31 @@ def _generate_posix_vars(): if _PYTHON_BUILD: vars['LDSHARED'] = vars['BLDSHARED'] - pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version[:3]) - if hasattr(sys, "gettotalrefcount"): - pybuilddir += '-pydebug' - os.makedirs(pybuilddir, exist_ok=True) - destfile = os.path.join(pybuilddir, '_sysconfigdata.py') - + # There's a chicken-and-egg situation on OS X with regards to the + # _sysconfigdata module after the changes introduced by #15298: + # get_config_vars() is called by get_platform() as part of the + # `make pybuilddir.txt` target -- which is a precursor to the + # _sysconfigdata.py module being constructed. Unfortunately, + # get_config_vars() eventually calls _init_posix(), which attempts + # to import _sysconfigdata, which we won't have built yet. So, + # write out _sysconfigdata.py to the current directory first, + # then call get_platform() to get the pybuilddir, then move it. + destfile = '_sysconfigdata.py' with open(destfile, 'w', encoding='utf8') as f: f.write('# system configuration generated and used by' ' the sysconfig module\n') f.write('build_time_vars = ') pprint.pprint(vars, stream=f) + pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version[:3]) + if hasattr(sys, "gettotalrefcount"): + pybuilddir += '-pydebug' + os.makedirs(pybuilddir, exist_ok=True) + target = os.path.join(pybuilddir, destfile) + + # Relocate _sysconfigdata.py into its final home. + os.rename(destfile, target) + # Create file used for sys.path fixup -- see Modules/getpath.c with open('pybuilddir.txt', 'w', encoding='ascii') as f: f.write(pybuilddir) |