[Python-checkins] commit of r41815 - sandbox/trunk/setuptools/setuptools/command/easy_install.py sandbox/trunk/setuptools/setuptools/command/install_scripts.py

phillip.eby python-checkins at python.org
Mon Dec 26 20:21:42 CET 2005


Author: phillip.eby
Date: Mon Dec 26 20:21:41 2005
New Revision: 41815

Modified:
   sandbox/trunk/setuptools/setuptools/command/easy_install.py
   sandbox/trunk/setuptools/setuptools/command/install_scripts.py
Log:
Make the install_scripts command respect the "build_scripts -e"
option when installing generated scripts using the
--single-version-externally-managed option.


Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/command/easy_install.py	(original)
+++ sandbox/trunk/setuptools/setuptools/command/easy_install.py	Mon Dec 26 20:21:41 2005
@@ -9,7 +9,6 @@
 
 __ http://peak.telecommunity.com/DevCenter/EasyInstall
 """
-
 import sys, os.path, zipimport, shutil, tempfile, zipfile, re, stat
 from glob import glob
 from setuptools import Command
@@ -23,6 +22,7 @@
 from setuptools.package_index import URL_SCHEME
 from setuptools.command import bdist_egg, egg_info
 from pkg_resources import *
+sys_executable = os.path.normpath(sys.executable)
 
 __all__ = [
     'samefile', 'easy_install', 'PthDistributions', 'extract_wininst_cfg',
@@ -1118,7 +1118,7 @@
         Environment.remove(self,dist)
 
 
-def get_script_header(script_text):
+def get_script_header(script_text, executable=sys_executable):
     """Create a #! line, getting options (if any) from script_text"""
     from distutils.command.build_scripts import first_line_re
     first, rest = (script_text+'\n').split('\n',1)
@@ -1129,7 +1129,6 @@
         options = match.group(1) or ''
         if options:
             options = ' '+options
-    executable = os.path.normpath(sys.executable)
     return "#!%(executable)s%(options)s\n" % locals()
 
 def main(argv=None, **kw):
@@ -1146,10 +1145,11 @@
     exc = sys.exc_info()
     raise exc[0], (exc[1][0], exc[1][1] + (" %s %s" % (func,arg)))
 
-def get_script_args(dist):
+
+def get_script_args(dist, executable=sys_executable):
     """Yield write_script() argument tuples for a distribution's entrypoints"""
     spec = str(dist.as_requirement())
-    header = get_script_header("")
+    header = get_script_header("", executable)
     for group in 'console_scripts', 'gui_scripts':
         for name,ep in dist.get_entry_map(group).items():
             script_text = (

Modified: sandbox/trunk/setuptools/setuptools/command/install_scripts.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/command/install_scripts.py	(original)
+++ sandbox/trunk/setuptools/setuptools/command/install_scripts.py	Mon Dec 26 20:21:41 2005
@@ -1,6 +1,6 @@
 from distutils.command.install_scripts import install_scripts \
      as _install_scripts
-from easy_install import get_script_args
+from easy_install import get_script_args, sys_executable
 from pkg_resources import Distribution, PathMetadata, ensure_directory
 import os
 from distutils import log
@@ -19,12 +19,12 @@
             ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
             ei_cmd.egg_name, ei_cmd.egg_version,
         )
-        for args in get_script_args(dist):
-            self.write_script(*args)
+        bs_cmd = self.get_finalized_command('build_scripts')
+        executable = getattr(bs_cmd,'executable',sys_executable)
+        for args in get_script_args(dist, executable): self.write_script(*args)
 
     def write_script(self, script_name, contents, mode="t", *ignored):
         """Write an executable file to the scripts directory"""
-
         log.info("Installing %s script to %s", script_name, self.install_dir)
         target = os.path.join(self.install_dir, script_name)
         self.outfiles.append(target)


More information about the Python-checkins mailing list