[Python-checkins] cpython (merge 3.5 -> default): Puts compiled pyc files into embedded library ZIP file instead of sources.
steve.dower
python-checkins at python.org
Wed Aug 5 01:03:42 CEST 2015
https://hg.python.org/cpython/rev/7c68d5d30441
changeset: 97255:7c68d5d30441
parent: 97253:6778332f687a
parent: 97254:984c4532f6f4
user: Steve Dower <steve.dower at microsoft.com>
date: Tue Aug 04 16:02:55 2015 -0700
summary:
Puts compiled pyc files into embedded library ZIP file instead of sources.
files:
Tools/msi/make_zip.py | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/Tools/msi/make_zip.py b/Tools/msi/make_zip.py
--- a/Tools/msi/make_zip.py
+++ b/Tools/msi/make_zip.py
@@ -1,4 +1,5 @@
import argparse
+import py_compile
import re
import sys
import shutil
@@ -82,7 +83,16 @@
with ZipFile(str(target), 'w', ZIP_DEFLATED) as f:
for s, rel in rel_sources:
- f.write(str(s), str(rel))
+ if rel.suffix.lower() == '.py':
+ pyc = Path(tempfile.gettempdir()) / rel.with_suffix('.pyc').name
+ try:
+ py_compile.compile(str(s), str(pyc), str(rel), doraise=True, optimize=2)
+ except py_compile.PyCompileError:
+ f.write(str(s), str(rel))
+ else:
+ f.write(str(pyc), str(rel.with_suffix('.pyc')))
+ else:
+ f.write(str(s), str(rel))
count += 1
else:
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list