cpython: 24d52d3060e8 (original) (raw)

Mercurial > cpython

changeset 79744:24d52d3060e8 3.3

Issue #15298: ensure _sysconfigdata is generated in build directory, not source directory. Patch by Richard Oudkerk (sbt). [#15298]

Trent Nelson trent@trent.me
date Tue, 16 Oct 2012 08:13:12 -0400
parents 0f56aa8e1046
children f85c3f4d9b98 a3f27289ec68 abb00e23681a
files Lib/sysconfig.py Makefile.pre.in Misc/NEWS setup.py
diffstat 4 files changed, 28 insertions(+), 28 deletions(-)[+] [-] Lib/sysconfig.py 11 Makefile.pre.in 24 Misc/NEWS 7 setup.py 14

line wrap: on

line diff

--- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -390,13 +390,22 @@ def _generate_posix_vars(): if _PYTHON_BUILD: vars['LDSHARED'] = vars['BLDSHARED']

+ 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)

+ def _init_posix(vars): """Initialize the module as appropriate for POSIX systems.""" # _sysconfigdata is generated at build time, see _generate_posix_vars()

--- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -410,8 +410,6 @@ OBJECT_OBJS= [](#l2.3) Objects/unicodectype.o [](#l2.4) Objects/weakrefobject.o -SYSCONFIGDATA=$(srcdir)/Lib/_sysconfigdata.py - ##########################################################################

objects that get linked into the Python library

LIBRARY_OBJS_OMIT_FROZEN= [](#l2.11) @@ -432,7 +430,7 @@ LIBRARY_OBJS= [](#l2.12)

Default target

all: build_all -build_all: (BUILDPYTHON)(BUILDPYTHON) (BUILDPYTHON)(SYSCONFIGDATA) oldsharedmods sharedmods gdbhooks Modules/_testembed +build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed

Compile a binary with gcc profile guided optimization.

profile-opt: @@ -466,17 +464,19 @@ coverage: (BUILDPYTHON):Modules/python.o(BUILDPYTHON): Modules/python.o (BUILDPYTHON):Modules/python.o(LIBRARY) (LDLIBRARY)(LDLIBRARY) (LDLIBRARY)(PY3LIBRARY) (LINKCC)(LINKCC) (LINKCC)(PY_LDFLAGS) (LINKFORSHARED)−o(LINKFORSHARED) -o (LINKFORSHARED)o@ Modules/python.o (BLDLIBRARY)(BLDLIBRARY) (BLDLIBRARY)(LIBS) (MODLIBS)(MODLIBS) (MODLIBS)(SYSLIBS) $(LDLAST) -platform: (BUILDPYTHON)(BUILDPYTHON) (BUILDPYTHON)(SYSCONFIGDATA) +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 -# Generate the sysconfig build-time data -$(SYSCONFIGDATA): $(BUILDPYTHON) +# 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

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

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

-sharedmods: (BUILDPYTHON)(BUILDPYTHON) (BUILDPYTHON)(SYSCONFIGDATA) +sharedmods: $(BUILDPYTHON) pybuilddir.txt @case "$$MAKEFLAGS" in [](#l2.42) s*) quiet="-q";; [](#l2.43) ) quiet="";; [](#l2.44) @@ -1043,7 +1043,7 @@ libinstall: build_all (srcdir)/Lib/(srcdir)/Lib/(srcdir)/Lib/(PL else true; [](#l2.46) fi; [](#l2.47) done - @for i in $(srcdir)/Lib/.py ; [](#l2.49) + @for i in $(srcdir)/Lib/*.py cat pybuilddir.txt/_sysconfigdata.py; [](#l2.50) do [](#l2.51) if test -x i; then [](#l2.52) (INSTALLSCRIPT)(INSTALL_SCRIPT) (INSTALLSCRIPT)$i (DESTDIR)(DESTDIR)(DESTDIR)(LIBDEST); [](#l2.53) @@ -1203,6 +1203,8 @@ sharedinstall: sharedmods --install-scripts=$(BINDIR) [](#l2.55) --install-platlib=$(DESTSHARED) [](#l2.56) --root=$(DESTDIR)/ + -rm (DESTDIR)(DESTDIR)(DESTDIR)(DESTSHARED)/_sysconfigdata.py + -rm -r (DESTDIR)(DESTDIR)(DESTDIR)(DESTSHARED)/pycache

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

framework-based Python. frameworkinstall installs everything, the

@@ -1348,9 +1350,10 @@ clean: pycremoval find . -name '.s[ol]' -exec rm -f {} ';' find . -name '.so.[0-9].[0-9]' -exec rm -f {} ';' find build -name 'fficonfig.h' -exec rm -f {} ';' || true - find build -name 'fficonfig.py' -exec rm -f {} ';' || true + find build -name '.py' -exec rm -f {} ';' || true + find build -name '.py[co]' -exec rm -f {} ';' || true + -rm -f pybuilddir.txt -rm -f Lib/lib2to3/Grammar.pickle - -rm -f $(SYSCONFIGDATA) -rm -f Modules/_testembed Modules/_freeze_importlib profile-removal: @@ -1374,7 +1377,6 @@ distclean: clobber Modules/Setup Modules/Setup.local Modules/Setup.config [](#l2.77) Modules/ld_so_aix Modules/python.exp Misc/python.pc -rm -f python*-gdb.py - -rm -f pybuilddir.txt find $(srcdir) '(' -name '.fdc' -o -name '~' [](#l2.81) -o -name '[@,#]' -o -name '.old' [](#l2.82) -o -name '.orig' -o -name '.rej' [](#l2.83)

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -127,6 +127,9 @@ Tests Build ----- +- Issue #15298: ensure _sysconfigdata is generated in build directory, not

--- a/setup.py +++ b/setup.py @@ -33,10 +33,6 @@ COMPILED_WITH_PYDEBUG = ('--with-pydebug

This global variable is used to hold the list of modules to be disabled.

disabled_module_list = [] -# File which contains the directory for shared mods (for sys.path fixup -# when running from the build dir, see Modules/getpath.c) -_BUILDDIR_COOKIE = "pybuilddir.txt" - def add_dir_to_list(dirlist, dir): """Add the directory 'dir' to the list 'dirlist' (after any relative directories) if: @@ -252,16 +248,6 @@ class PyBuildExt(build_ext): args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags self.compiler.set_executables(**args)

- build_ext.build_extensions(self) longest = max([len(e.name) for e in self.extensions])