diff options
author | Steve Dower <steve.dower@microsoft.com> | 2015-08-04 23:02:55 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2015-08-04 23:02:55 (GMT) |
commit | ec3e16a0f461cee26253da5da7eba131e9e79252 (patch) | |
tree | 923083bdd826e1197ba9492235691fca97374aa5 /Tools | |
parent | 8c81711d6c42531e74b14d2d697c3bf4fd2fdedd (diff) | |
parent | 08b1817fd88317243e143c64009da8f9d5474981 (diff) | |
download | cpython-ec3e16a0f461cee26253da5da7eba131e9e79252.zip cpython-ec3e16a0f461cee26253da5da7eba131e9e79252.tar.gz cpython-ec3e16a0f461cee26253da5da7eba131e9e79252.tar.bz2 |
Puts compiled pyc files into embedded library ZIP file instead of sources.
Diffstat (limited to 'Tools')
-rw-r--r-- | 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 index 521ba93..bace19a 100644 --- 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 @@ def copy_to_layout(target, rel_sources): 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: |