summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Deily <nad@acm.org>2012-09-08 19:04:47 -0700
committerNed Deily <nad@acm.org>2012-09-08 19:04:47 -0700
commitcf9ac3ee045cc581a728638dcdb97f74386e1465 (patch)
tree914eb03c9a573210dd4a109ab5a6ecddad59af35
parentad9913285e1396716c192883510c0febdb7c2b94 (diff)
downloadcpython-cf9ac3ee045cc581a728638dcdb97f74386e1465.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/NEWS3
3 files changed, 25 insertions, 3 deletions
diff --git a/Lib/lib2to3/pgen2/driver.py b/Lib/lib2to3/pgen2/driver.py
index e7828ffe16..4c611c6640 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 f715711d9e..d42c938451 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1017,8 +1017,6 @@ LIBSUBDIRS= tkinter tkinter/test tkinter/test/test_tkinter \
venv venv/scripts venv/scripts/posix \
curses pydoc_data $(MACHDEPS)
libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -Wi -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
@for i in $(SCRIPTDIR) $(LIBDEST); \
do \
if test ! -d $(DESTDIR)$$i; then \
@@ -1096,6 +1094,10 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
$(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
# Create the PLATDIR source directory, if one wasn't distributed..
$(srcdir)/Lib/$(PLATDIR):
@@ -1340,7 +1342,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
-rm -f $(SYSCONFIGDATA)
-rm -f Modules/_testembed Modules/_freeze_importlib
diff --git a/Misc/NEWS b/Misc/NEWS
index 802d984832..12e4c4aeb7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -141,6 +141,9 @@ Extension Modules
Tools/Demos
-----------
+- Issue #15822: Really ensure 2to3 grammar pickles are properly installed
+ (replaces fixes for Issue #15645).
+
Documentation
-------------