(original) (raw)
changeset: 78895:adc5e6aca251 branch: 3.2 parent: 78891:8c60bb098eff user: Ned Deily nad@acm.org date: Sat Sep 08 18:50:56 2012 -0700 files: Lib/lib2to3/pgen2/driver.py Makefile.pre.in Misc/NEWS description: Issue #15822: Fix installation of lib2to3 grammar pickles to ensure they are created in the install locations and with the proper timestamp. (Solution suggested by MvL) diff -r 8c60bb098eff -r adc5e6aca251 Lib/lib2to3/pgen2/driver.py --- a/Lib/lib2to3/pgen2/driver.py Sat Sep 08 16:45:35 2012 -0400 +++ b/Lib/lib2to3/pgen2/driver.py Sat Sep 08 18:50:56 2012 -0700 @@ -138,3 +138,20 @@ if not os.path.exists(b): return True return os.path.getmtime(a) >= os.path.getmtime(b) + + +def main(*args): + """Main program, when run as a script: produce grammar pickle files. + + Calls load_grammar for each argument, a path to a grammar text file. + """ + if not args: + args = sys.argv[1:] + logging.basicConfig(level=logging.INFO, stream=sys.stdout, + format='%(message)s') + for gt in args: + load_grammar(gt, save=True, force=True) + return True + +if __name__ == "__main__": + sys.exit(int(not main())) diff -r 8c60bb098eff -r adc5e6aca251 Makefile.pre.in --- a/Makefile.pre.in Sat Sep 08 16:45:35 2012 -0400 +++ b/Makefile.pre.in Sat Sep 08 18:50:56 2012 -0700 @@ -945,8 +945,6 @@ unittest unittest/test \ curses pydoc_data (MACHDEPS)libinstall:buildall(MACHDEPS) libinstall: build_all (MACHDEPS)libinstall:buildall(srcdir)/Lib/$(PLATDIR) (srcdir)/Modules/xxmodule.c−−PYTHONPATH=(srcdir)/Modules/xxmodule.c - -PYTHONPATH=(srcdir)/Modules/xxmodule.c−−PYTHONPATH=(DESTDIR)$(LIBDEST) (RUNSHARED)−./(RUNSHARED) \ - ./(RUNSHARED)−./(BUILDPYTHON) -Wi -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()" @for i in (SCRIPTDIR)(SCRIPTDIR) (SCRIPTDIR)(LIBDEST); \ do \ if test ! -d (DESTDIR)(DESTDIR)(DESTDIR)$i; then \ @@ -1024,6 +1022,10 @@ ./$(BUILDPYTHON) -Wi -O (DESTDIR)(DESTDIR)(DESTDIR)(LIBDEST)/compileall.py \ -d (LIBDEST)/site−packages−f−xbadsyntax(LIBDEST)/site-packages -f \ -x badsyntax (LIBDEST)/site−packages−f−xbadsyntax(DESTDIR)$(LIBDEST)/site-packages + -PYTHONPATH=$(DESTDIR)$(LIBDEST) (RUNSHARED)+./(RUNSHARED) \ + ./(RUNSHARED)+./(BUILDPYTHON) -m lib2to3.pgen2.driver (DESTDIR)(DESTDIR)(DESTDIR)(LIBDEST)/lib2to3/Grammar.txt + -PYTHONPATH=$(DESTDIR)$(LIBDEST) (RUNSHARED)+./(RUNSHARED) \ + ./(RUNSHARED)+./(BUILDPYTHON) -m lib2to3.pgen2.driver (DESTDIR)(DESTDIR)(DESTDIR)(LIBDEST)/lib2to3/PatternGrammar.txt # Create the PLATDIR source directory, if one wasn't distributed.. (srcdir)/Lib/(srcdir)/Lib/(srcdir)/Lib/(PLATDIR): @@ -1264,7 +1266,7 @@ 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 - -rm -f $(srcdir)/Lib/lib2to3/*Grammar*.pickle + -rm -f Lib/lib2to3/*Grammar*.pickle -rm -f Modules/_testembed profile-removal: diff -r 8c60bb098eff -r adc5e6aca251 Misc/NEWS --- a/Misc/NEWS Sat Sep 08 16:45:35 2012 -0400 +++ b/Misc/NEWS Sat Sep 08 18:50:56 2012 -0700 @@ -525,7 +525,7 @@ - Issue #15819: Make sure we can build Python out-of-tree from a readonly source directory. (Somewhat related to Issue #9860.) -- Issue #15645: Ensure 2to3 grammar pickles are properly installed. +- Issue #15822: Ensure 2to3 grammar pickles are properly installed. - Issue #15560: Fix building _sqlite3 extension on OS X with an SDK. /nad@acm.org