summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Deily <nad@acm.org>2012-09-08 18:47:27 -0700
committerNed Deily <nad@acm.org>2012-09-08 18:47:27 -0700
commit10fc104fede2449468fb9488bb44a9663382b3a8 (patch)
treeb40010b50230907c0cc16d830d0536dd30883784
parentb9495c78a16c9fc0ddf55caa88f5eeda959da002 (diff)
downloadcpython-git-10fc104fede2449468fb9488bb44a9663382b3a8.tar.gz
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)
-rw-r--r--Lib/lib2to3/pgen2/driver.py17
-rw-r--r--Makefile.pre.in8
-rw-r--r--Misc/NEWS2
3 files changed, 23 insertions, 4 deletions
diff --git a/Lib/lib2to3/pgen2/driver.py b/Lib/lib2to3/pgen2/driver.py
index 16adec057f..39dafb92ac 100644
--- a/Lib/lib2to3/pgen2/driver.py
+++ b/Lib/lib2to3/pgen2/driver.py
@@ -138,3 +138,20 @@ def _newer(a, b):
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 --git a/Makefile.pre.in b/Makefile.pre.in
index e56a870c3a..2bb68447ad 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -887,8 +887,6 @@ LIBSUBDIRS= lib-tk lib-tk/test lib-tk/test/test_tkinter \
lib-old \
curses pydoc_data $(MACHDEPS)
libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
@for i in $(SCRIPTDIR) $(LIBDEST); \
do \
if test ! -d $(DESTDIR)$$i; then \
@@ -966,6 +964,10 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ ./$(BUILDPYTHON) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ ./$(BUILDPYTHON) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
# Create the PLATDIR source directory, if one wasn't distributed..
$(srcdir)/Lib/$(PLATDIR):
@@ -1203,7 +1205,7 @@ clean: pycremoval
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
profile-removal:
find . -name '*.gc??' -exec rm -f {} ';'
diff --git a/Misc/NEWS b/Misc/NEWS
index e02e1d774c..c0736199b7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -388,7 +388,7 @@ Build
- 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.