Commit 199f4f67 authored by PJ Eby's avatar PJ Eby

Make the install_scripts command respect the "build_scripts -e"

option when installing generated scripts using the
--single-version-externally-managed option.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041815
parent f3bed845
......@@ -9,7 +9,6 @@ file, or visit the `EasyInstall home page`__.
__ 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 PackageIndex, parse_bdist_wininst
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 @@ class PthDistributions(Environment):
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 @@ def get_script_header(script_text):
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 @@ def auto_chmod(func, arg, exc):
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 = (
......
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 @@ class install_scripts(_install_scripts):
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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment