diff options
author | Steve Dower <steve.dower@microsoft.com> | 2015-08-05 18:34:50 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2015-08-05 18:34:50 (GMT) |
commit | 315b748cfc5d64d606d12a73ac81051da32419c3 (patch) | |
tree | b6147854a50461d82f3105bde56f32fb2ad6d105 /Tools | |
parent | 6703d032a5a695051a1c24847de6d35fd9842242 (diff) | |
download | cpython-315b748cfc5d64d606d12a73ac81051da32419c3.zip cpython-315b748cfc5d64d606d12a73ac81051da32419c3.tar.gz cpython-315b748cfc5d64d606d12a73ac81051da32419c3.tar.bz2 |
Fixes make_zip.py to create temporary .pyc files in a separate directory. This avoids polluting tests that run code from TEMP.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/msi/make_zip.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Tools/msi/make_zip.py b/Tools/msi/make_zip.py index bace19a..ba711c4 100644 --- a/Tools/msi/make_zip.py +++ b/Tools/msi/make_zip.py @@ -82,18 +82,19 @@ def copy_to_layout(target, rel_sources): target.unlink() with ZipFile(str(target), 'w', ZIP_DEFLATED) as f: - for s, rel in rel_sources: - 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)) + with tempfile.TemporaryDirectory() as tmpdir: + for s, rel in rel_sources: + if rel.suffix.lower() == '.py': + pyc = Path(tmpdir) / 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(pyc), str(rel.with_suffix('.pyc'))) - else: - f.write(str(s), str(rel)) - count += 1 + f.write(str(s), str(rel)) + count += 1 else: for s, rel in rel_sources: |