cpython: a0614e041bc8 (original) (raw)
Mercurial > cpython
changeset 79806:a0614e041bc8
Merge issue #15298. [#15298]
Trent Nelson trent@trent.me | |
---|---|
date | Wed, 17 Oct 2012 18:05:27 -0400 |
parents | 240fa6e93925(current diff)1250498db562(diff) |
children | f6fcff683866 |
files | Lib/sysconfig.py |
diffstat | 1 files changed, 18 insertions(+), 13 deletions(-)[+] [-] Lib/sysconfig.py 31 |
line wrap: on
line diff
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -377,25 +377,30 @@ def _generate_posix_vars():
# 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'
to import _sysconfigdata, which we won't have built yet. In order
for _init_posix() to work, if we're on Darwin, just mock up the
_sysconfigdata module manually and populate it with the build vars.
This is more than sufficient for ensuring the subsequent call to
get_platform() succeeds.
- name = '_sysconfigdata'
- if 'darwin' in sys.platform:
import imp[](#l1.18)
module = imp.new_module(name)[](#l1.19)
module.build_time_vars = vars[](#l1.20)
sys.modules[name] = module[](#l1.21)
- pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version[:3])
- if hasattr(sys, "gettotalrefcount"):
pybuilddir += '-pydebug'[](#l1.25)
- os.makedirs(pybuilddir, exist_ok=True)
- destfile = os.path.join(pybuilddir, name + '.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'[](#l1.37)
- os.makedirs(pybuilddir, exist_ok=True)
- target = os.path.join(pybuilddir, destfile)
- # Create file used for sys.path fixup -- see Modules/getpath.c with open('pybuilddir.txt', 'w', encoding='ascii') as f: f.write(pybuilddir)