[Python-checkins] cpython: Issue #15822: Fix installation of lib2to3 grammar pickles to ensure
ned.deily
python-checkins at python.org
Sun Sep 9 04:08:59 CEST 2012
http://hg.python.org/cpython/rev/a829889f96b0
changeset: 78897:a829889f96b0
user: Ned Deily <nad at acm.org>
date: Sat Sep 08 19:04:47 2012 -0700
summary:
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)
files:
Lib/lib2to3/pgen2/driver.py | 17 +++++++++++++++++
Makefile.pre.in | 8 +++++---
Misc/NEWS | 3 +++
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/Lib/lib2to3/pgen2/driver.py b/Lib/lib2to3/pgen2/driver.py
--- a/Lib/lib2to3/pgen2/driver.py
+++ b/Lib/lib2to3/pgen2/driver.py
@@ -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 --git a/Makefile.pre.in b/Makefile.pre.in
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1024,8 +1024,6 @@
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 \
@@ -1103,6 +1101,10 @@
$(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):
@@ -1347,7 +1349,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 $(SYSCONFIGDATA)
-rm -f Modules/_testembed Modules/_freeze_importlib
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -62,6 +62,9 @@
- Issue #15819: Make sure we can build Python out-of-tree from a readonly
source directory. (Somewhat related to Issue #9860.)
+- Issue #15822: Really ensure 2to3 grammar pickles are properly installed
+ (replaces fixes for Issue #15645).
+
Documentation
-------------
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list