diff -r e6dce5611dae -r 6510f2df0d81 Lib/sysconfig.py --- a/Lib/sysconfig.py Mon Jun 02 22:58:13 2014 -0700 +++ b/Lib/sysconfig.py Wed Jun 04 14:54:38 2014 +0200 @@ -690,12 +690,51 @@ print('%s: ' % (title)) print('\t%s = "%s"' % (key, value)) +def _generate_config_file(filename, template = None): + if not filename: + filename = '-' + if not template: + template = filename == '-' and filename or filename + '.in' + if not filename == '-' and filename == template: + raise ValueError( + "output filename '%s' must be different from input filename '%s'" + % (filename, template)) + + # build regex "@prefix@|@libdir@|@LIBPL@|..." + import re + rexstr = '' + sep = '' + vars = get_config_vars() + for k, v in vars.items(): + rexstr += sep + '@'+k+'@' + sep = '|' + rex = re.compile(rexstr) + + with filename == '-' and sys.stdout or open(filename, 'w') as outfile: + with template == '-' and sys.stdin or open(template, 'r') as infile: + for line in infile: + while True: + found = rex.search(line) + if not found: + outfile.write(line) + break + value = vars.get(found.group(0)[1:-1]) + outfile.write(line[:found.span()[0]] + str(value)) + line = line[found.span()[1]:] + pass def _main(): """Display all information sysconfig detains.""" if '--generate-posix-vars' in sys.argv: _generate_posix_vars() return + if '--generate-config-file' in sys.argv: + for arg in sys.argv: + param, sep, value = arg.partition('=') + if param == '--file': # see config.status --help + file, sep, template = value.partition(':') + _generate_config_file(file, template) + return print('Platform: "%s"' % get_platform()) print('Python version: "%s"' % get_python_version()) print('Current installation scheme: "%s"' % _get_default_scheme()) diff -r e6dce5611dae -r 6510f2df0d81 Makefile.pre.in --- a/Makefile.pre.in Mon Jun 02 22:58:13 2014 -0700 +++ b/Makefile.pre.in Wed Jun 04 14:54:38 2014 +0200 @@ -337,6 +337,11 @@ ########################################################################## # Python +PYCONFIGFILES = \ + Misc/python.pc \ + Misc/python-config.sh \ + Misc/python-config + OPCODETARGETS_H= \ Python/opcode_targets.h @@ -459,7 +464,7 @@ # Default target all: build_all -build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed python-config +build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed $(PYCONFIGFILES) # Compile a binary with gcc profile guided optimization. profile-opt: @@ -1261,19 +1266,18 @@ fi; \ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen -python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh - # Substitution happens here, as the completely-expanded BINDIR - # is not available in configure - sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py - # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR} - sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config - # On Darwin, always use the python version of the script, the shell - # version doesn't use the compiler customizations that are provided - # in python (_osx_support.py). - if test `uname -s` = Darwin; then \ - cp python-config.py python-config; \ - fi +Misc/python.pc: $(srcdir)/Misc/python.pc.in +Misc/python-config: $(srcdir)/Misc/python-config.in +Misc/python-config.sh: $(srcdir)/Misc/python-config.sh.in +# Besides a common subset, both sysconfig and config.status provide variables +# not known to the other. While config.status provides the configured values, +# sysconfig provides values with variable-references resolved already: +# Substitute sysconfig values first, and remaining ones with config.status. +$(PYCONFIGFILES): $(BUILDPYTHON) pybuilddir.txt + $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig \ + --generate-config-file --file=-:$(srcdir)/$@.in | \ + $(SHELL) config.status --file=$@:- # Install the include files INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY) @@ -1300,7 +1304,7 @@ # pkgconfig directory LIBPC= $(LIBDIR)/pkgconfig -libainstall: all python-config +libainstall: all $(PYCONFIGFILES) @for i in $(LIBDIR) $(LIBPL) $(LIBPC); \ do \ if test ! -d $(DESTDIR)$$i; then \ @@ -1331,8 +1335,14 @@ $(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh - $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py - $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config + $(INSTALL_SCRIPT) Misc/python-config $(DESTDIR)$(LIBPL)/python-config.py + $(INSTALL_SCRIPT) Misc/python-config.sh $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config + # On Darwin, always use the python version of the script, the shell + # version doesn't use the compiler customizations that are provided + # in python (_osx_support.py). + if test `uname -s` = Darwin; then \ + $(INSTALL_SCRIPT) Misc/python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config; \ + fi @if [ -s Modules/python.exp -a \ "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \ echo; echo "Installing support files for building shared extension modules on AIX:"; \ @@ -1529,7 +1539,7 @@ config.cache config.log pyconfig.h Modules/config.c -rm -rf build platform -rm -rf $(PYTHONFRAMEWORKDIR) - -rm -f python-config.py python-config + -rm -f $(PYCONFIGFILES) # Make things extra clean, before making a distribution: # remove all generated files, even Makefile[.pre] @@ -1540,7 +1550,7 @@ done -rm -f core Makefile Makefile.pre config.status \ Modules/Setup Modules/Setup.local Modules/Setup.config \ - Modules/ld_so_aix Modules/python.exp Misc/python.pc + Modules/ld_so_aix Modules/python.exp -rm -f python*-gdb.py find $(srcdir)/[a-zA-Z]* '(' -name '*.fdc' -o -name '*~' \ -o -name '[@,#]*' -o -name '*.old' \ diff -r e6dce5611dae -r 6510f2df0d81 Misc/python-config.in --- a/Misc/python-config.in Mon Jun 02 22:58:13 2014 -0700 +++ b/Misc/python-config.in Wed Jun 04 14:54:38 2014 +0200 @@ -1,4 +1,4 @@ -#!@EXENAME@ +#!@BINDIR@/python@LDVERSION@@EXE@ # -*- python -*- # Keep this script in sync with python-config.sh.in diff -r e6dce5611dae -r 6510f2df0d81 configure --- a/configure Mon Jun 02 22:58:13 2014 -0700 +++ b/configure Wed Jun 04 14:54:38 2014 +0200 @@ -15401,7 +15401,7 @@ # generate output files -ac_config_files="$ac_config_files Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh" +ac_config_files="$ac_config_files Makefile.pre Modules/Setup.config" ac_config_files="$ac_config_files Modules/ld_so_aix" @@ -16104,8 +16104,6 @@ "Mac/Resources/app/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/app/Info.plist" ;; "Makefile.pre") CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;; "Modules/Setup.config") CONFIG_FILES="$CONFIG_FILES Modules/Setup.config" ;; - "Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;; - "Misc/python-config.sh") CONFIG_FILES="$CONFIG_FILES Misc/python-config.sh" ;; "Modules/ld_so_aix") CONFIG_FILES="$CONFIG_FILES Modules/ld_so_aix" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff -r e6dce5611dae -r 6510f2df0d81 configure.ac --- a/configure.ac Mon Jun 02 22:58:13 2014 -0700 +++ b/configure.ac Wed Jun 04 14:54:38 2014 +0200 @@ -4796,7 +4796,7 @@ AC_SUBST(ENSUREPIP) # generate output files -AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh) +AC_CONFIG_FILES(Makefile.pre Modules/Setup.config) AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) AC_OUTPUT