Python3: allow configuration of BUILD_LEGACY_PYC

This commit is contained in:
Rudi Heitbaum 2023-08-01 08:48:12 +00:00
parent f9e11f1f60
commit a72c630719
2 changed files with 10 additions and 5 deletions

View File

@ -89,6 +89,10 @@ pre_configure_host() {
export PYTHON_MODULES_INCLUDE="${HOST_INCDIR}"
export PYTHON_MODULES_LIB="${HOST_LIBDIR}"
export DISABLED_EXTENSIONS="readline _curses _curses_panel ${PKG_PY_DISABLED_MODULES}"
# control patch Python3-0300-generate-legacy-pyc-bytecode
# this needs to be set when building host based py file
# do not set this for py compiles being done for target use
export DONT_BUILD_LEGACY_PYC=1
}
post_make_host() {

View File

@ -19,18 +19,19 @@ generates legacy bytecode.
https://www.python.org/dev/peps/pep-3147/#case-4-legacy-pyc-files-and-source-less-imports
---
Lib/py_compile.py | 4 ++++
1 file changed, 4 insertions(+)
Lib/py_compile.py | 5 +++++
1 file changed, 5 insertions(+)
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -121,6 +121,10 @@ def compile(file, cfile=None, dfile=None
@@ -121,6 +121,11 @@ def compile(file, cfile=None, dfile=None
the resulting file would be regular and thus not the same type of file as
it was previously.
"""
+
+ if cfile:
+ cfile = file + 'c'
+ if os.environ.get('DONT_BUILD_LEGACY_PYC') is None:
+ if cfile:
+ cfile = file + 'c'
+
if invalidation_mode is None:
invalidation_mode = _get_default_invalidation_mode()