diff --git a/newsfragments/4934.feature.rst b/newsfragments/4934.feature.rst new file mode 100644 index 0000000000..96abb169a1 --- /dev/null +++ b/newsfragments/4934.feature.rst @@ -0,0 +1 @@ +Restored support for install_scripts --executable (and classic behavior for the executable for those invocations). Instead, build_editable provides the portable form of the executables for downstream installers to rewrite. diff --git a/setuptools/_distutils/command/build_scripts.py b/setuptools/_distutils/command/build_scripts.py index 127c51d8dc..b86ee6e6ba 100644 --- a/setuptools/_distutils/command/build_scripts.py +++ b/setuptools/_distutils/command/build_scripts.py @@ -106,7 +106,7 @@ def _copy_script(self, script, outfiles, updated_files): log.info("copying and adjusting %s -> %s", script, self.build_dir) if not self.dry_run: post_interp = shebang_match.group(1) or '' - shebang = f"#!python{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) diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index 1a544ec258..917d5f149b 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -211,6 +211,11 @@ def _configure_build( install.install_headers = headers install.install_data = data + # For portability, ensure scripts are built with #!python shebang + # pypa/setuptools#4863 + build_scripts = dist.get_command_obj("build_scripts") + build_scripts.executable = 'python' + install_scripts = cast( install_scripts_cls, dist.get_command_obj("install_scripts") )