From a72c630719af8c053e978182b2031b7cda092926 Mon Sep 17 00:00:00 2001 From: Rudi Heitbaum Date: Tue, 1 Aug 2023 08:48:12 +0000 Subject: [PATCH] Python3: allow configuration of BUILD_LEGACY_PYC --- packages/lang/Python3/package.mk | 4 ++++ .../Python3-0300-generate-legacy-pyc-bytecode.patch | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/lang/Python3/package.mk b/packages/lang/Python3/package.mk index b4a32671b4..4e65615fb6 100644 --- a/packages/lang/Python3/package.mk +++ b/packages/lang/Python3/package.mk @@ -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() { diff --git a/packages/lang/Python3/patches/Python3-0300-generate-legacy-pyc-bytecode.patch b/packages/lang/Python3/patches/Python3-0300-generate-legacy-pyc-bytecode.patch index b4cc4ba3a9..37c9e8d82c 100644 --- a/packages/lang/Python3/patches/Python3-0300-generate-legacy-pyc-bytecode.patch +++ b/packages/lang/Python3/patches/Python3-0300-generate-legacy-pyc-bytecode.patch @@ -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()