diff options
author | Yi Zhao <yi.zhao@windriver.com> | 2025-09-20 14:17:52 +0800 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2025-09-25 12:25:51 -0700 |
commit | cb23f1e13634a0518c74c10b04c69bed1f799f8a (patch) | |
tree | 1a58dc2c56a0fc05bc77a054b43dd7aa93be8bba | |
parent | 9bdfaa121a658bfaa752f68875bb9a2dcec66e79 (diff) | |
download | poky-cb23f1e13634a0518c74c10b04c69bed1f799f8a.tar.gz |
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 <yi.zhao@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
3 files changed, 124 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3-setuptools/0001-Revert-Merge-pull-request-pypa-distutils-332-from-py.patch b/meta/recipes-devtools/python/python3-setuptools/0001-Revert-Merge-pull-request-pypa-distutils-332-from-py.patch new file mode 100644 index 0000000000..e3329246b9 --- /dev/null +++ b/meta/recipes-devtools/python/python3-setuptools/0001-Revert-Merge-pull-request-pypa-distutils-332-from-py.patch | |||
@@ -0,0 +1,63 @@ | |||
1 | From a8d07038ec4813a743bdc0313556c9b0fd65ba88 Mon Sep 17 00:00:00 2001 | ||
2 | From: "Jason R. Coombs" <jaraco@jaraco.com> | ||
3 | Date: Fri, 2 May 2025 20:01:23 -0400 | ||
4 | Subject: [PATCH] Revert "Merge pull request pypa/distutils#332 from | ||
5 | pypa/debt/unify-shebang" | ||
6 | |||
7 | This reverts commit 5589d7527044a75ff681ceb4e1e97641578a0c87, reversing | ||
8 | changes made to 250c300096abbf4147be62a428bd25a98abc487e. | ||
9 | |||
10 | Closes pypa/setuptools#4934 | ||
11 | |||
12 | Upstream-Status: Backport | ||
13 | [https://github.com/pypa/setuptools/commit/3f94782c5ede0689cfc216693ddb9a79087d6c91] | ||
14 | |||
15 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> | ||
16 | --- | ||
17 | setuptools/_distutils/command/build_scripts.py | 15 +++++++++++++-- | ||
18 | 1 file changed, 13 insertions(+), 2 deletions(-) | ||
19 | |||
20 | diff --git a/setuptools/_distutils/command/build_scripts.py b/setuptools/_distutils/command/build_scripts.py | ||
21 | index 127c51d..3f7aae0 100644 | ||
22 | --- a/setuptools/_distutils/command/build_scripts.py | ||
23 | +++ b/setuptools/_distutils/command/build_scripts.py | ||
24 | @@ -5,6 +5,7 @@ Implements the Distutils 'build_scripts' command.""" | ||
25 | import os | ||
26 | import re | ||
27 | import tokenize | ||
28 | +from distutils import sysconfig | ||
29 | from distutils._log import log | ||
30 | from stat import ST_MODE | ||
31 | from typing import ClassVar | ||
32 | @@ -75,7 +76,7 @@ class build_scripts(Command): | ||
33 | |||
34 | return outfiles, updated_files | ||
35 | |||
36 | - def _copy_script(self, script, outfiles, updated_files): | ||
37 | + def _copy_script(self, script, outfiles, updated_files): # noqa: C901 | ||
38 | shebang_match = None | ||
39 | script = convert_path(script) | ||
40 | outfile = os.path.join(self.build_dir, os.path.basename(script)) | ||
41 | @@ -105,8 +106,18 @@ class build_scripts(Command): | ||
42 | if shebang_match: | ||
43 | log.info("copying and adjusting %s -> %s", script, self.build_dir) | ||
44 | if not self.dry_run: | ||
45 | + if not sysconfig.python_build: | ||
46 | + executable = self.executable | ||
47 | + else: | ||
48 | + executable = os.path.join( | ||
49 | + sysconfig.get_config_var("BINDIR"), | ||
50 | + "python{}{}".format( | ||
51 | + sysconfig.get_config_var("VERSION"), | ||
52 | + sysconfig.get_config_var("EXE"), | ||
53 | + ), | ||
54 | + ) | ||
55 | post_interp = shebang_match.group(1) or '' | ||
56 | - shebang = f"#!python{post_interp}\n" | ||
57 | + shebang = "#!" + executable + post_interp + "\n" | ||
58 | self._validate_shebang(shebang, f.encoding) | ||
59 | with open(outfile, "w", encoding=f.encoding) as outf: | ||
60 | outf.write(shebang) | ||
61 | -- | ||
62 | 2.34.1 | ||
63 | |||
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 @@ | |||
1 | From 3b2944f3d9f83129500571f9e44fb0779bf0987b Mon Sep 17 00:00:00 2001 | ||
2 | From: "Jason R. Coombs" <jaraco@jaraco.com> | ||
3 | Date: Fri, 2 May 2025 20:07:13 -0400 | ||
4 | Subject: [PATCH] Remove support for special executable under a Python build. | ||
5 | |||
6 | As far as I can tell, no one has complained about loss of this functionality. | ||
7 | |||
8 | Upstream-Status: Backport | ||
9 | [https://github.com/pypa/setuptools/commit/575445c672d78fcce22df1e459b7baf0304a38b9] | ||
10 | |||
11 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> | ||
12 | --- | ||
13 | setuptools/_distutils/command/build_scripts.py | 15 ++------------- | ||
14 | 1 file changed, 2 insertions(+), 13 deletions(-) | ||
15 | |||
16 | diff --git a/setuptools/_distutils/command/build_scripts.py b/setuptools/_distutils/command/build_scripts.py | ||
17 | index 3f7aae0..b86ee6e 100644 | ||
18 | --- a/setuptools/_distutils/command/build_scripts.py | ||
19 | +++ b/setuptools/_distutils/command/build_scripts.py | ||
20 | @@ -5,7 +5,6 @@ Implements the Distutils 'build_scripts' command.""" | ||
21 | import os | ||
22 | import re | ||
23 | import tokenize | ||
24 | -from distutils import sysconfig | ||
25 | from distutils._log import log | ||
26 | from stat import ST_MODE | ||
27 | from typing import ClassVar | ||
28 | @@ -76,7 +75,7 @@ class build_scripts(Command): | ||
29 | |||
30 | return outfiles, updated_files | ||
31 | |||
32 | - def _copy_script(self, script, outfiles, updated_files): # noqa: C901 | ||
33 | + def _copy_script(self, script, outfiles, updated_files): | ||
34 | shebang_match = None | ||
35 | script = convert_path(script) | ||
36 | outfile = os.path.join(self.build_dir, os.path.basename(script)) | ||
37 | @@ -106,18 +105,8 @@ class build_scripts(Command): | ||
38 | if shebang_match: | ||
39 | log.info("copying and adjusting %s -> %s", script, self.build_dir) | ||
40 | if not self.dry_run: | ||
41 | - if not sysconfig.python_build: | ||
42 | - executable = self.executable | ||
43 | - else: | ||
44 | - executable = os.path.join( | ||
45 | - sysconfig.get_config_var("BINDIR"), | ||
46 | - "python{}{}".format( | ||
47 | - sysconfig.get_config_var("VERSION"), | ||
48 | - sysconfig.get_config_var("EXE"), | ||
49 | - ), | ||
50 | - ) | ||
51 | post_interp = shebang_match.group(1) or '' | ||
52 | - shebang = "#!" + executable + post_interp + "\n" | ||
53 | + shebang = "#!" + self.executable + post_interp + "\n" | ||
54 | self._validate_shebang(shebang, f.encoding) | ||
55 | with open(outfile, "w", encoding=f.encoding) as outf: | ||
56 | outf.write(shebang) | ||
57 | -- | ||
58 | 2.34.1 | ||
59 | |||
diff --git a/meta/recipes-devtools/python/python3-setuptools_76.0.0.bb b/meta/recipes-devtools/python/python3-setuptools_76.0.0.bb index 91d8fdd73b..9f330ec54e 100644 --- a/meta/recipes-devtools/python/python3-setuptools_76.0.0.bb +++ b/meta/recipes-devtools/python/python3-setuptools_76.0.0.bb | |||
@@ -14,6 +14,8 @@ SRC_URI += " \ | |||
14 | file://0001-_distutils-sysconfig.py-make-it-possible-to-substite.patch \ | 14 | file://0001-_distutils-sysconfig.py-make-it-possible-to-substite.patch \ |
15 | file://CVE-2025-47273-pre1.patch \ | 15 | file://CVE-2025-47273-pre1.patch \ |
16 | file://CVE-2025-47273.patch \ | 16 | file://CVE-2025-47273.patch \ |
17 | file://0001-Revert-Merge-pull-request-pypa-distutils-332-from-py.patch \ | ||
18 | file://0002-Remove-support-for-special-executable-under-a-Python.patch \ | ||
17 | " | 19 | " |
18 | 20 | ||
19 | SRC_URI[sha256sum] = "43b4ee60e10b0d0ee98ad11918e114c70701bc6051662a9a675a0496c1a158f4" | 21 | SRC_URI[sha256sum] = "43b4ee60e10b0d0ee98ad11918e114c70701bc6051662a9a675a0496c1a158f4" |