Commit 2170df35 authored by Jason R. Coombs's avatar Jason R. Coombs

Move decision logic about windows/header generation closer to install_scripts,...

Move decision logic about windows/header generation closer to install_scripts, as it doesn't appear to be used elsewhere.
parent aabff231
...@@ -745,7 +745,7 @@ Please make the appropriate changes for your system and try again. ...@@ -745,7 +745,7 @@ Please make the appropriate changes for your system and try again.
def install_wrapper_scripts(self, dist): def install_wrapper_scripts(self, dist):
if not self.exclude_scripts: if not self.exclude_scripts:
for args in get_script_args(dist): for args in ScriptWriter._gen_args(dist):
self.write_script(*args) self.write_script(*args)
def install_script(self, dist, script_name, script_text, dev_path=None): def install_script(self, dist, script_name, script_text, dev_path=None):
...@@ -921,7 +921,7 @@ Please make the appropriate changes for your system and try again. ...@@ -921,7 +921,7 @@ Please make the appropriate changes for your system and try again.
# delete entry-point scripts to avoid duping # delete entry-point scripts to avoid duping
self.delete_blockers( self.delete_blockers(
[os.path.join(script_dir, args[0]) for args in [os.path.join(script_dir, args[0]) for args in
get_script_args(dist)] ScriptWriter._gen_args(dist)]
) )
# Build .egg file from tmpdir # Build .egg file from tmpdir
bdist_egg.make_zipfile( bdist_egg.make_zipfile(
...@@ -1902,15 +1902,18 @@ class ScriptWriter(object): ...@@ -1902,15 +1902,18 @@ class ScriptWriter(object):
@classmethod @classmethod
def get_script_args(cls, dist, executable=sys_executable, wininst=False): def get_script_args(cls, dist, executable=sys_executable, wininst=False):
""" # for backward compatibility
Yield write_script() argument tuples for a distribution's entrypoints
"""
writer = cls.get_writer(wininst) writer = cls.get_writer(wininst)
header = get_script_header("", executable, wininst) header = get_script_header("", executable, wininst)
return writer._gen_args(dist, header) return writer._gen_args(dist, header)
@classmethod @classmethod
def _gen_args(cls, dist, header): def _gen_args(cls, dist, header=None):
"""
Yield write_script() argument tuples for a distribution's entrypoints
"""
if header is None:
header = get_script_header("", sys_executable)
spec = str(dist.as_requirement()) spec = str(dist.as_requirement())
for type_ in 'console', 'gui': for type_ in 'console', 'gui':
group = type_ + '_scripts' group = type_ + '_scripts'
......
...@@ -13,9 +13,9 @@ class install_scripts(orig.install_scripts): ...@@ -13,9 +13,9 @@ class install_scripts(orig.install_scripts):
self.no_ep = False self.no_ep = False
def run(self): def run(self):
from setuptools.command.easy_install import get_script_args from setuptools.command.easy_install import (
from setuptools.command.easy_install import sys_executable ScriptWriter, sys_executable, get_script_header,
)
self.run_command("egg_info") self.run_command("egg_info")
if self.distribution.scripts: if self.distribution.scripts:
orig.install_scripts.run(self) # run first to set up self.outfiles orig.install_scripts.run(self) # run first to set up self.outfiles
...@@ -35,7 +35,9 @@ class install_scripts(orig.install_scripts): ...@@ -35,7 +35,9 @@ class install_scripts(orig.install_scripts):
is_wininst = getattr( is_wininst = getattr(
self.get_finalized_command("bdist_wininst"), '_is_running', False self.get_finalized_command("bdist_wininst"), '_is_running', False
) )
for args in get_script_args(dist, executable, is_wininst): writer = ScriptWriter.get_writer(force_windows=is_wininst)
header = get_script_header("", executable, wininst=is_wininst)
for args in writer._gen_args(dist, header):
self.write_script(*args) self.write_script(*args)
def write_script(self, script_name, contents, mode="t", *ignored): def write_script(self, script_name, contents, mode="t", *ignored):
......
...@@ -22,8 +22,8 @@ from setuptools import compat ...@@ -22,8 +22,8 @@ from setuptools import compat
from setuptools.compat import StringIO, BytesIO, urlparse from setuptools.compat import StringIO, BytesIO, urlparse
from setuptools.sandbox import run_setup, SandboxViolation from setuptools.sandbox import run_setup, SandboxViolation
from setuptools.command.easy_install import ( from setuptools.command.easy_install import (
easy_install, fix_jython_executable, get_script_args, nt_quote_arg, easy_install, fix_jython_executable, nt_quote_arg,
get_script_header, is_sh, get_script_header, is_sh, ScriptWriter,
) )
from setuptools.command.easy_install import PthDistributions from setuptools.command.easy_install import PthDistributions
from setuptools.command import easy_install as easy_install_pkg from setuptools.command import easy_install as easy_install_pkg
...@@ -83,7 +83,7 @@ class TestEasyInstallTest: ...@@ -83,7 +83,7 @@ class TestEasyInstallTest:
def test_get_script_args(self): def test_get_script_args(self):
dist = FakeDist() dist = FakeDist()
args = next(get_script_args(dist)) args = next(ScriptWriter._gen_args(dist))
name, script = itertools.islice(args, 2) name, script = itertools.islice(args, 2)
assert script == WANTED assert script == WANTED
......
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