Blob Blame History Raw
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 6d85a31..cd9f9ac 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -147,7 +147,9 @@ class easy_install(Command):
          "allow building eggs from local checkouts"),
         ('version', None, "print version information and exit"),
         ('no-find-links', None,
-         "Don't load find-links defined in packages being installed")
+         "Don't load find-links defined in packages being installed"),
+        ('executable=', 'e',
+         "specify final destination interpreter path")
     ]
     boolean_options = [
         'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy',
@@ -210,6 +212,7 @@ class easy_install(Command):
         self.distribution._set_command_options(
             self, self.distribution.get_option_dict('easy_install')
         )
+        self.executable = None

     def delete_blockers(self, blockers):
         extant_blockers = (
@@ -359,6 +362,8 @@ class easy_install(Command):
                 "No urls, filenames, or requirements specified (see --help)")

         self.outputs = []
+        if self.executable is None:
+            self.executable = os.path.normpath(sys.executable)

     def _fix_install_dir_for_user_site(self):
         """
@@ -786,7 +791,8 @@ class easy_install(Command):
     def install_wrapper_scripts(self, dist):
         if self.exclude_scripts:
             return
-        for args in ScriptWriter.best().get_args(dist):
+        for args in ScriptWriter.best().get_args(
+            dist, executable=self.executable):
             self.write_script(*args)

     def install_script(self, dist, script_name, script_text, dev_path=None):
@@ -972,7 +978,7 @@ class easy_install(Command):
         # delete entry-point scripts to avoid duping
         self.delete_blockers([
             os.path.join(script_dir, args[0])
-            for args in ScriptWriter.get_args(dist)
+            for args in ScriptWriter.get_args(dist, executable=self.executable)
         ])
         # Build .egg file from tmpdir
         bdist_egg.make_zipfile(
@@ -2042,13 +2048,13 @@ class ScriptWriter(object):
         return cmd.as_header()

     @classmethod
-    def get_args(cls, dist, header=None):
+    def get_args(cls, dist, header=None, executable=None):
         """
         Yield write_script() argument tuples for a distribution's
         console_scripts and gui_scripts entry points.
         """
         if header is None:
-            header = cls.get_header()
+            header = cls.get_header(executable=executable)
         spec = str(dist.as_requirement())
         for type_ in 'console', 'gui':
             group = type_ + '_scripts'
diff --git a/setuptools/command/install.py b/setuptools/command/install.py
index 31a5ddb..e468d05 100644
--- a/setuptools/command/install.py
+++ b/setuptools/command/install.py
@@ -99,6 +99,7 @@ class install(orig.install):

         cmd = easy_install(
             self.distribution, args="x", root=self.root, record=self.record,
+            executable=self.executable,
         )
         cmd.ensure_finalized()  # finalize before bdist_egg munges install cmd
         cmd.always_copy_from = '.'  # make sure local-dir eggs get installed
diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py
index 1623427..570415d 100755
--- a/setuptools/command/install_scripts.py
+++ b/setuptools/command/install_scripts.py
@@ -30,7 +30,8 @@ class install_scripts(orig.install_scripts):
             ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
             ei_cmd.egg_name, ei_cmd.egg_version,
         )
-        bs_cmd = self.get_finalized_command('build_scripts')
+        bs_cmd = (self.get_finalized_command('build_scripts', create=False) or
+                  self.get_finalized_command('install'))
         exec_param = getattr(bs_cmd, 'executable', None)
         bw_cmd = self.get_finalized_command("bdist_wininst")
         is_wininst = getattr(bw_cmd, '_is_running', False)