Skip to content

Commit

Permalink
Merge pull request pypa/distutils#332 from pypa/debt/unify-shebang
Browse files Browse the repository at this point in the history
In build_scripts, unconditionally set shebang to #!python.
  • Loading branch information
jaraco authored Mar 9, 2025
2 parents 250c300 + eecd653 commit 5589d75
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions distutils/command/build_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import re
import tokenize
from distutils import sysconfig
from distutils._log import log
from stat import ST_MODE
from typing import ClassVar
Expand Down Expand Up @@ -76,7 +75,7 @@ def copy_scripts(self):

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))
Expand Down Expand Up @@ -106,18 +105,8 @@ def _copy_script(self, script, outfiles, updated_files): # noqa: C901
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 = f"#!python{post_interp}\n"
self._validate_shebang(shebang, f.encoding)
with open(outfile, "w", encoding=f.encoding) as outf:
outf.write(shebang)
Expand Down

0 comments on commit 5589d75

Please sign in to comment.