1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
Description: revert "Always rewrite a Python shebang to #!python"
In Debian, we have no /usr/bin/python executable, and this change
broke build of some packages.
.
This reverts commit c71266345c64fd662b5f95bbbc6e4536172f496d.
Author: Dmitry Shachnev <mitya57@debian.org>
Forwarded: not-needed
Last-Update: 2025-04-18
--- a/setuptools/_distutils/command/build_scripts.py
+++ b/setuptools/_distutils/command/build_scripts.py
@@ -5,6 +5,7 @@ Implements the Distutils 'build_scripts'
import os
import re
import tokenize
+from distutils import sysconfig
from distutils._log import log
from stat import ST_MODE
from typing import ClassVar
@@ -105,8 +106,18 @@ 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 = f"#!python{post_interp}\n"
+ shebang = "#!" + executable + post_interp + "\n"
self._validate_shebang(shebang, f.encoding)
with open(outfile, "w", encoding=f.encoding) as outf:
outf.write(shebang)
|