summaryrefslogtreecommitdiffstats
path: root/PC/layout
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2019-01-08 10:38:01 (GMT)
committerGitHub <noreply@github.com>2019-01-08 10:38:01 (GMT)
commit872bd2b57ce8e4ea7a54acb3934222c0e4e7276b (patch)
treecda6cc6c3823daa9bec4cd93ffc64c2bf54e886e /PC/layout
parentc24c6c2c9357da99961bf257078240529181daf3 (diff)
downloadcpython-872bd2b57ce8e4ea7a54acb3934222c0e4e7276b.zip
cpython-872bd2b57ce8e4ea7a54acb3934222c0e4e7276b.tar.gz
cpython-872bd2b57ce8e4ea7a54acb3934222c0e4e7276b.tar.bz2
bpo-35596: Use unchecked PYCs for the embeddable distro to avoid zipimport restrictions (GH-11465)
Also adds extra steps to the CI build for Windows on Azure Pipelines to validate that the various layouts at least execute.
Diffstat (limited to 'PC/layout')
-rw-r--r--PC/layout/main.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/PC/layout/main.py b/PC/layout/main.py
index 7eaf201..d372fe5 100644
--- a/PC/layout/main.py
+++ b/PC/layout/main.py
@@ -240,12 +240,18 @@ def get_layout(ns):
yield "DLLs/{}".format(ns.include_cat.name), ns.include_cat
-def _compile_one_py(src, dest, name, optimize):
+def _compile_one_py(src, dest, name, optimize, checked=True):
import py_compile
if dest is not None:
dest = str(dest)
+ mode = (
+ py_compile.PycInvalidationMode.CHECKED_HASH
+ if checked
+ else py_compile.PycInvalidationMode.UNCHECKED_HASH
+ )
+
try:
return Path(
py_compile.compile(
@@ -254,7 +260,7 @@ def _compile_one_py(src, dest, name, optimize):
str(name),
doraise=True,
optimize=optimize,
- invalidation_mode=py_compile.PycInvalidationMode.CHECKED_HASH,
+ invalidation_mode=mode,
)
)
except py_compile.PyCompileError:
@@ -262,16 +268,16 @@ def _compile_one_py(src, dest, name, optimize):
return None
-def _py_temp_compile(src, ns, dest_dir=None):
+def _py_temp_compile(src, ns, dest_dir=None, checked=True):
if not ns.precompile or src not in PY_FILES or src.parent in DATA_DIRS:
return None
dest = (dest_dir or ns.temp) / (src.stem + ".py")
- return _compile_one_py(src, dest.with_suffix(".pyc"), dest, optimize=2)
+ return _compile_one_py(src, dest.with_suffix(".pyc"), dest, optimize=2, checked=checked)
-def _write_to_zip(zf, dest, src, ns):
- pyc = _py_temp_compile(src, ns)
+def _write_to_zip(zf, dest, src, ns, checked=True):
+ pyc = _py_temp_compile(src, ns, checked=checked)
if pyc:
try:
zf.write(str(pyc), dest.with_suffix(".pyc"))
@@ -321,7 +327,7 @@ def generate_source_files(ns):
ns.temp.mkdir(parents=True, exist_ok=True)
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf:
for dest, src in get_lib_layout(ns):
- _write_to_zip(zf, dest, src, ns)
+ _write_to_zip(zf, dest, src, ns, checked=False)
if ns.include_underpth:
log_info("Generating {} in {}", PYTHON_PTH_NAME, ns.temp)