0001-Revert-Merge-pull-request-pypa-distutils-332-from-py.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. This reverts commit 5589d7527044a75ff681ceb4e1e97641578a0c87, reversing
  7. changes made to 250c300096abbf4147be62a428bd25a98abc487e.
  8. Closes pypa/setuptools#4934
  9. Upstream-Status: Backport
  10. [https://github.com/pypa/setuptools/commit/3f94782c5ede0689cfc216693ddb9a79087d6c91]
  11. Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
  12. ---
  13. setuptools/_distutils/command/build_scripts.py | 15 +++++++++++++--
  14. 1 file changed, 13 insertions(+), 2 deletions(-)
  15. diff --git a/setuptools/_distutils/command/build_scripts.py b/setuptools/_distutils/command/build_scripts.py
  16. index 127c51d..3f7aae0 100644
  17. --- a/setuptools/_distutils/command/build_scripts.py
  18. +++ b/setuptools/_distutils/command/build_scripts.py
  19. @@ -5,6 +5,7 @@ Implements the Distutils 'build_scripts' command."""
  20. import os
  21. import re
  22. import tokenize
  23. +from distutils import sysconfig
  24. from distutils._log import log
  25. from stat import ST_MODE
  26. from typing import ClassVar
  27. @@ -75,7 +76,7 @@ class build_scripts(Command):
  28. return outfiles, updated_files
  29. - def _copy_script(self, script, outfiles, updated_files):
  30. + def _copy_script(self, script, outfiles, updated_files): # noqa: C901
  31. shebang_match = None
  32. script = convert_path(script)
  33. outfile = os.path.join(self.build_dir, os.path.basename(script))
  34. @@ -105,8 +106,18 @@ class build_scripts(Command):
  35. if shebang_match:
  36. log.info("copying and adjusting %s -> %s", script, self.build_dir)
  37. if not self.dry_run:
  38. + if not sysconfig.python_build:
  39. + executable = self.executable
  40. + else:
  41. + executable = os.path.join(
  42. + sysconfig.get_config_var("BINDIR"),
  43. + "python{}{}".format(
  44. + sysconfig.get_config_var("VERSION"),
  45. + sysconfig.get_config_var("EXE"),
  46. + ),
  47. + )
  48. post_interp = shebang_match.group(1) or ''
  49. - shebang = f"#!python{post_interp}\n"
  50. + shebang = "#!" + executable + post_interp + "\n"
  51. self._validate_shebang(shebang, f.encoding)
  52. with open(outfile, "w", encoding=f.encoding) as outf:
  53. outf.write(shebang)
  54. --
  55. 2.34.1