[2/3] python3-pip: Don't change shebang

Message ID 20220223200726.3279678-2-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 8ceb0bec18422818dcdb0efecec08ed155dc4715
Headers show
Series [1/3] pip_install_wheel: Use --ignore-installed for pip | expand

Commit Message

Richard Purdie Feb. 23, 2022, 8:07 p.m. UTC
Patch pip to disable shebang mangling and also force the python executable
to be python3 from the environment when building anything for the target
(or nativesdk).

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 .../python3-pip/no_shebang_mangling.patch     | 24 +++++++++++++++++++
 .../python/python3-pip_22.0.3.bb              |  1 +
 2 files changed, 25 insertions(+)
 create mode 100644 meta/recipes-devtools/python/python3-pip/no_shebang_mangling.patch

Patch

diff --git a/meta/recipes-devtools/python/python3-pip/no_shebang_mangling.patch b/meta/recipes-devtools/python/python3-pip/no_shebang_mangling.patch
new file mode 100644
index 00000000000..e4dfcbcf843
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-pip/no_shebang_mangling.patch
@@ -0,0 +1,24 @@ 
+Upstream-Status: Inappropriate [OE specific config]
+
+Index: pip-22.0.3/src/pip/_vendor/distlib/scripts.py
+===================================================================
+--- pip-22.0.3.orig/src/pip/_vendor/distlib/scripts.py
++++ pip-22.0.3/src/pip/_vendor/distlib/scripts.py
+@@ -135,6 +135,8 @@ class ScriptMaker(object):
+         See also: http://www.in-ulm.de/~mascheck/various/shebang/#length
+                   https://hg.mozilla.org/mozilla-central/file/tip/mach
+         """
++        if '_PYTHON_SYSCONFIGDATA_NAME' in os.environ:
++            return b'#!/usr/bin/env python3'
+         if os.name != 'posix':
+             simple_shebang = True
+         else:
+@@ -340,7 +342,7 @@ class ScriptMaker(object):
+                 return
+ 
+             match = FIRST_LINE_RE.match(first_line.replace(b'\r\n', b'\n'))
+-            if match:
++            if False:
+                 adjust = True
+                 post_interp = match.group(1) or b''
+ 
diff --git a/meta/recipes-devtools/python/python3-pip_22.0.3.bb b/meta/recipes-devtools/python/python3-pip_22.0.3.bb
index c4671f50175..023ab41810d 100644
--- a/meta/recipes-devtools/python/python3-pip_22.0.3.bb
+++ b/meta/recipes-devtools/python/python3-pip_22.0.3.bb
@@ -13,6 +13,7 @@  DEPENDS:remove:class-native = "python3-pip-native"
 DEPENDS:append:class-native = " unzip-native"
 
 SRC_URI += "file://0001-change-shebang-to-python3.patch"
+SRC_URI += "file://no_shebang_mangling.patch"
 
 SRC_URI[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0"