1From 975379e84ae3229fac94cd0499fd4ba7baa574ba Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
3Date: Mon, 7 Dec 2015 01:14:33 +0100
4Subject: [PATCH] add executable
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Add a new --executable option to distribute so that we can
10force the shebang line in installed python scripts.
11
12[Thomas: refresh for setuptools 5.8.]
13[Jörg: refresh for setuptools 18.7.1]
14
15Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
16Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
17Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
18Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
19---
20 setuptools/command/install.py         | 2 ++
21 setuptools/command/install_scripts.py | 9 +++++++++
22 2 files changed, 11 insertions(+)
23
24diff --git a/setuptools/command/install.py b/setuptools/command/install.py
25index 606cce9d8..f158e1b51 100644
26--- a/setuptools/command/install.py
27+++ b/setuptools/command/install.py
28@@ -16,6 +16,7 @@ class install(orig.install):
29     """Use easy_install to install the package, w/dependencies"""
30
31     user_options = orig.install.user_options + [
32+        ('executable=', 'e', "specify final destination interpreter path"),
33         ('old-and-unmanageable', None, "Try not to use this!"),
34         (
35             'single-version-externally-managed',
36@@ -48,6 +49,7 @@ class install(orig.install):
37         )
38
39         orig.install.initialize_options(self)
40+        self.executable = None
41         self.old_and_unmanageable = None
42         self.single_version_externally_managed = None
43
44diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py
45index 72b2e45cb..146a0bb58 100644
46--- a/setuptools/command/install_scripts.py
47+++ b/setuptools/command/install_scripts.py
48@@ -12,6 +12,13 @@ class install_scripts(orig.install_scripts):
49     def initialize_options(self):
50         orig.install_scripts.initialize_options(self)
51         self.no_ep = False
52+        self.executable = None
53+
54+    def finalize_options(self):
55+        orig.install_scripts.finalize_options(self)
56+        self.set_undefined_options('install',
57+                ('executable','executable')
58+        )
59
60     def run(self):
61         self.run_command("egg_info")
62@@ -38,6 +45,8 @@ class install_scripts(orig.install_scripts):
63         )
64         bs_cmd = self.get_finalized_command('build_scripts')
65         exec_param = getattr(bs_cmd, 'executable', None)
66+        if self.executable is not None:
67+            exec_param = self.executable
68         writer = ei.ScriptWriter
69         if exec_param == sys.executable:
70             # In case the path to the Python executable contains a space, wrap
71--
722.34.1
73
74