Commit 921fc3e2 authored by Jason R. Coombs's avatar Jason R. Coombs

Renamed .get_writer to .best and removed boolean argument.

parent 21ebac85
...@@ -10,6 +10,8 @@ CHANGES ...@@ -10,6 +10,8 @@ CHANGES
``build.executable``, such that an executable of "/usr/bin/env my-python" may ``build.executable``, such that an executable of "/usr/bin/env my-python" may
be specified. This means that systems with a specified executable whose name be specified. This means that systems with a specified executable whose name
has spaces in the path must be updated to escape or quote that value. has spaces in the path must be updated to escape or quote that value.
* Deprecated ``easy_install.ScriptWriter.get_writer``, replaced by ``.best()``
with slightly different semantics (no force_windows flag).
------ ------
11.3.1 11.3.1
......
...@@ -742,7 +742,7 @@ Please make the appropriate changes for your system and try again. ...@@ -742,7 +742,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 ScriptWriter.get_args(dist): for args in ScriptWriter.best().get_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):
...@@ -1975,7 +1975,7 @@ class ScriptWriter(object): ...@@ -1975,7 +1975,7 @@ class ScriptWriter(object):
def get_script_args(cls, dist, executable=None, wininst=False): def get_script_args(cls, dist, executable=None, wininst=False):
# for backward compatibility # for backward compatibility
warnings.warn("Use get_args", DeprecationWarning) warnings.warn("Use get_args", DeprecationWarning)
writer = cls.get_writer(wininst) writer = (WindowsScriptWriter if wininst else ScriptWriter).best()
header = cls.get_script_header("", executable, wininst) header = cls.get_script_header("", executable, wininst)
return writer.get_args(dist, header) return writer.get_args(dist, header)
...@@ -2007,9 +2007,16 @@ class ScriptWriter(object): ...@@ -2007,9 +2007,16 @@ class ScriptWriter(object):
@classmethod @classmethod
def get_writer(cls, force_windows): def get_writer(cls, force_windows):
if force_windows or sys.platform == 'win32': # for backward compatibility
return WindowsScriptWriter.get_writer() warnings.warn("Use best", DeprecationWarning)
return cls return WindowsScriptWriter.best() if force_windows else cls.best()
@classmethod
def best(cls):
"""
Select the best ScriptWriter for this environment.
"""
return WindowsScriptWriter.best() if sys.platform == 'win32' else cls
@classmethod @classmethod
def _get_script_args(cls, type_, name, header, script_text): def _get_script_args(cls, type_, name, header, script_text):
...@@ -2027,8 +2034,14 @@ class ScriptWriter(object): ...@@ -2027,8 +2034,14 @@ class ScriptWriter(object):
class WindowsScriptWriter(ScriptWriter): class WindowsScriptWriter(ScriptWriter):
@classmethod @classmethod
def get_writer(cls): def get_writer(cls):
# for backward compatibility
warnings.warn("Use best", DeprecationWarning)
return cls.best()
@classmethod
def best(cls):
""" """
Get a script writer suitable for Windows Select the best ScriptWriter suitable for Windows
""" """
writer_lookup = dict( writer_lookup = dict(
executable=WindowsExecutableLauncherWriter, executable=WindowsExecutableLauncherWriter,
......
...@@ -13,7 +13,7 @@ class install_scripts(orig.install_scripts): ...@@ -13,7 +13,7 @@ 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 ScriptWriter, CommandSpec import setuptools.command.easy_install as ei
self.run_command("egg_info") self.run_command("egg_info")
if self.distribution.scripts: if self.distribution.scripts:
...@@ -30,14 +30,15 @@ class install_scripts(orig.install_scripts): ...@@ -30,14 +30,15 @@ class install_scripts(orig.install_scripts):
ei_cmd.egg_name, ei_cmd.egg_version, ei_cmd.egg_name, ei_cmd.egg_version,
) )
bs_cmd = self.get_finalized_command('build_scripts') bs_cmd = self.get_finalized_command('build_scripts')
cmd = CommandSpec.from_param(getattr(bs_cmd, 'executable', None)) cmd = ei.CommandSpec.from_param(getattr(bs_cmd, 'executable', None))
is_wininst = getattr( is_wininst = getattr(
self.get_finalized_command("bdist_wininst"), '_is_running', False self.get_finalized_command("bdist_wininst"), '_is_running', False
) )
writer = ei.ScriptWriter
if is_wininst: if is_wininst:
cmd = CommandSpec.from_string("python.exe") cmd = ei.CommandSpec.from_string("python.exe")
writer = ScriptWriter.get_writer(force_windows=is_wininst) writer = ei.WindowsScriptWriter
for args in writer.get_args(dist, cmd.as_header()): for args in writer.best().get_args(dist, cmd.as_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):
......
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