cpython: 66e30c4870bb (original) (raw)

Mercurial > cpython

changeset 82872:66e30c4870bb 2.7

- Issue #13150: sysconfig no longer parses the Makefile and config.h files when imported, instead doing it at build time. This makes importing sysconfig faster and reduces Python startup time by 20%. [#13150]

doko@ubuntu.com
date Thu, 21 Mar 2013 15:02:16 -0700
parents 71adf21421d9
children d6336b2e4db6
files Lib/distutils/sysconfig.py Lib/pprint.py Lib/sysconfig.py Makefile.pre.in Misc/NEWS
diffstat 5 files changed, 93 insertions(+), 66 deletions(-)[+] [-] Lib/distutils/sysconfig.py 63 Lib/pprint.py 5 Lib/sysconfig.py 75 Makefile.pre.in 12 Misc/NEWS 4

line wrap: on

line diff

--- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -387,66 +387,11 @@ def expand_makefile_vars(s, vars): def _init_posix(): """Initialize the module as appropriate for POSIX systems."""

-

-

-

-

-

-

-

-

-

def _init_nt():

--- a/Lib/pprint.py +++ b/Lib/pprint.py @@ -37,7 +37,10 @@ saferepr() import sys as _sys import warnings -from cStringIO import StringIO as _StringIO +try:

+except ImportError:

all = ["pprint","pformat","isreadable","isrecursive","saferepr", "PrettyPrinter"]

--- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -278,9 +278,10 @@ def _get_makefile_filename(): return os.path.join(_PROJECT_BASE, "Makefile") return os.path.join(get_path('platstdlib'), "config", "Makefile") - -def _init_posix(vars):

+def _generate_posix_vars():

+

+

+

+ +def _init_posix(vars):

+ def _init_non_posix(vars): """Initialize the module as appropriate for NT""" # set basic install directories @@ -565,3 +609,28 @@ def get_platform(): def get_python_version(): return _PY_VERSION_SHORT + + +def _print_dict(title, data):

+ + +def _main():

+ + +if name == 'main':

--- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -437,15 +437,20 @@ coverage: Modules/python.o [](#l4.4) (BLDLIBRARY)(BLDLIBRARY) (BLDLIBRARY)(LIBS) (MODLIBS)(MODLIBS) (MODLIBS)(SYSLIBS) $(LDLAST) -platform: $(BUILDPYTHON) +platform: $(BUILDPYTHON) pybuilddir.txt (RUNSHARED)(RUNSHARED) (RUNSHARED)(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform +# Create build directory and generate the sysconfig build-time data there. +# pybuilddir.txt contains the name of the build dir and is used for +# sys.path fixup -- see Modules/getpath.c. +pybuilddir.txt: $(BUILDPYTHON) + (RUNSHARED)(RUNSHARED) (RUNSHARED)(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars

Build the shared modules

Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for

-s, --silent or --quiet is always the first char.

Under BSD make, MAKEFLAGS might be " -s -v x=y".

-sharedmods: $(BUILDPYTHON) +sharedmods: $(BUILDPYTHON) pybuilddir.txt @case "$$MAKEFLAGS" in [](#l4.23) \ -s|s*) quiet="-q";; [](#l4.24) ) quiet="";; [](#l4.25) @@ -955,7 +960,7 @@ libinstall: build_all (srcdir)/Lib/(srcdir)/Lib/(srcdir)/Lib/(PL else true; [](#l4.27) fi; [](#l4.28) done - @for i in (srcdir)/Lib/∗.py(srcdir)/Lib/.py (srcdir)/Lib/.py(srcdir)/Lib/.doc $(srcdir)/Lib/.egg-info ; [](#l4.30) + @for i in (srcdir)/Lib/∗.py‘catpybuilddir.txt‘/sysconfigdata.py(srcdir)/Lib/.py cat pybuilddir.txt/_sysconfigdata.py (srcdir)/Lib/.pycatpybuilddir.txt/sysconfigdata.py(srcdir)/Lib/.doc $(srcdir)/Lib/.egg-info ; [](#l4.31) do [](#l4.32) if test -x i; then [](#l4.33) (INSTALLSCRIPT)(INSTALL_SCRIPT) (INSTALLSCRIPT)$i (DESTDIR)(DESTDIR)(DESTDIR)(LIBDEST); [](#l4.34) @@ -1133,6 +1138,7 @@ sharedinstall: sharedmods --install-scripts=$(BINDIR) [](#l4.36) --install-platlib=$(DESTSHARED) [](#l4.37) --root=$(DESTDIR)/ + -rm (DESTDIR)(DESTDIR)(DESTDIR)(DESTSHARED)/_sysconfigdata.py

Here are a couple of targets for MacOSX again, to install a full

framework-based Python. frameworkinstall installs everything, the

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -216,6 +216,10 @@ Core and Builtins Library ------- +- Issue #13150: sysconfig no longer parses the Makefile and config.h files