From cb23f1e13634a0518c74c10b04c69bed1f799f8a Mon Sep 17 00:00:00 2001 From: Yi Zhao Date: Sat, 20 Sep 2025 14:17:52 +0800 Subject: python3-setuptools: restore build_scripts.executable support We encountered an issue when running python scripts provided by python3-fail2ban. The shebang '#!/usr/bin/env python3' was replaced by '#!python', which caused these scripts to fail to run. For example: $ head -n 1 /usr/bin/fail2ban-testcases #!python $ /usr/bin/fail2ban-testcases -sh: /usr/bin/fail2ban-testcases: cannot execute: required file not found This issue was introduced by commit[1] in python3-setuptools 75.3.2. See the upstream issue report[2] for more information. Backport patches from [3] to fix this issue. [1] https://github.com/pypa/setuptools/commit/c71266345c64fd662b5f95bbbc6e4536172f496d [2] https://github.com/pypa/setuptools/issues/4934 [3] https://github.com/pypa/distutils/pull/358 (From OE-Core rev: d728ec95291f05cbfb436eabe8717ebe9a0dc11d) Signed-off-by: Yi Zhao Signed-off-by: Steve Sakoman --- ...ort-for-special-executable-under-a-Python.patch | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 meta/recipes-devtools/python/python3-setuptools/0002-Remove-support-for-special-executable-under-a-Python.patch (limited to 'meta/recipes-devtools/python/python3-setuptools/0002-Remove-support-for-special-executable-under-a-Python.patch') diff --git a/meta/recipes-devtools/python/python3-setuptools/0002-Remove-support-for-special-executable-under-a-Python.patch b/meta/recipes-devtools/python/python3-setuptools/0002-Remove-support-for-special-executable-under-a-Python.patch new file mode 100644 index 0000000000..ea3fd22331 --- /dev/null +++ b/meta/recipes-devtools/python/python3-setuptools/0002-Remove-support-for-special-executable-under-a-Python.patch @@ -0,0 +1,59 @@ +From 3b2944f3d9f83129500571f9e44fb0779bf0987b Mon Sep 17 00:00:00 2001 +From: "Jason R. Coombs" +Date: Fri, 2 May 2025 20:07:13 -0400 +Subject: [PATCH] Remove support for special executable under a Python build. + +As far as I can tell, no one has complained about loss of this functionality. + +Upstream-Status: Backport +[https://github.com/pypa/setuptools/commit/575445c672d78fcce22df1e459b7baf0304a38b9] + +Signed-off-by: Yi Zhao +--- + setuptools/_distutils/command/build_scripts.py | 15 ++------------- + 1 file changed, 2 insertions(+), 13 deletions(-) + +diff --git a/setuptools/_distutils/command/build_scripts.py b/setuptools/_distutils/command/build_scripts.py +index 3f7aae0..b86ee6e 100644 +--- a/setuptools/_distutils/command/build_scripts.py ++++ b/setuptools/_distutils/command/build_scripts.py +@@ -5,7 +5,6 @@ Implements the Distutils 'build_scripts' command.""" + import os + import re + import tokenize +-from distutils import sysconfig + from distutils._log import log + from stat import ST_MODE + from typing import ClassVar +@@ -76,7 +75,7 @@ class build_scripts(Command): + + return outfiles, updated_files + +- def _copy_script(self, script, outfiles, updated_files): # noqa: C901 ++ def _copy_script(self, script, outfiles, updated_files): + shebang_match = None + script = convert_path(script) + outfile = os.path.join(self.build_dir, os.path.basename(script)) +@@ -106,18 +105,8 @@ class build_scripts(Command): + if shebang_match: + log.info("copying and adjusting %s -> %s", script, self.build_dir) + if not self.dry_run: +- if not sysconfig.python_build: +- executable = self.executable +- else: +- executable = os.path.join( +- sysconfig.get_config_var("BINDIR"), +- "python{}{}".format( +- sysconfig.get_config_var("VERSION"), +- sysconfig.get_config_var("EXE"), +- ), +- ) + post_interp = shebang_match.group(1) or '' +- shebang = "#!" + executable + post_interp + "\n" ++ shebang = "#!" + self.executable + post_interp + "\n" + self._validate_shebang(shebang, f.encoding) + with open(outfile, "w", encoding=f.encoding) as outf: + outf.write(shebang) +-- +2.34.1 + -- cgit v1.2.3-54-g00ecf