aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/easy_install.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-01-04 16:43:55 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-01-04 16:43:55 -0500
commitef9c3db451e2f24fc8821287e79a1ef48e0c5cf5 (patch)
tree593c1a05c19e836efb41259c76f644aa34726679 /setuptools/command/easy_install.py
parent2170df350911390a4a9a205763475dc7a7a2fb54 (diff)
downloadexternal_python_setuptools-ef9c3db451e2f24fc8821287e79a1ef48e0c5cf5.tar.gz
external_python_setuptools-ef9c3db451e2f24fc8821287e79a1ef48e0c5cf5.tar.bz2
external_python_setuptools-ef9c3db451e2f24fc8821287e79a1ef48e0c5cf5.zip
Move get_script_header into ScriptWriter
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-xsetuptools/command/easy_install.py50
1 files changed, 26 insertions, 24 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index d8d11d50..c2928c77 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -1593,30 +1593,8 @@ def _first_line_re():
def get_script_header(script_text, executable=sys_executable, wininst=False):
- """Create a #! line, getting options (if any) from script_text"""
- first = (script_text + '\n').splitlines()[0]
- match = _first_line_re().match(first)
- options = ''
- if match:
- options = match.group(1) or ''
- if options:
- options = ' ' + options
- if wininst:
- executable = "python.exe"
- else:
- executable = nt_quote_arg(executable)
- hdr = "#!%(executable)s%(options)s\n" % locals()
- if not isascii(hdr):
- # Non-ascii path to sys.executable, use -x to prevent warnings
- if options:
- if options.strip().startswith('-'):
- options = ' -x' + options.strip()[1:]
- # else: punt, we can't do it, let the warning happen anyway
- else:
- options = ' -x'
- executable = fix_jython_executable(executable, options)
- hdr = "#!%(executable)s%(options)s\n" % locals()
- return hdr
+ executable = "python.exe" if wininst else nt_quote_arg(executable)
+ return ScriptWriter.get_header(script_text, executable)
def auto_chmod(func, arg, exc):
@@ -1903,6 +1881,7 @@ class ScriptWriter(object):
@classmethod
def get_script_args(cls, dist, executable=sys_executable, wininst=False):
# for backward compatibility
+ warnings.warn("Use _gen_args", DeprecationWarning)
writer = cls.get_writer(wininst)
header = get_script_header("", executable, wininst)
return writer._gen_args(dist, header)
@@ -1934,6 +1913,29 @@ class ScriptWriter(object):
# Simply write the stub with no extension.
yield (name, header + script_text)
+ @classmethod
+ def get_header(cls, script_text, executable):
+ """Create a #! line, getting options (if any) from script_text"""
+ first = (script_text + '\n').splitlines()[0]
+ match = _first_line_re().match(first)
+ options = ''
+ if match:
+ options = match.group(1) or ''
+ if options:
+ options = ' ' + options
+ hdr = "#!%(executable)s%(options)s\n" % locals()
+ if not isascii(hdr):
+ # Non-ascii path to sys.executable, use -x to prevent warnings
+ if options:
+ if options.strip().startswith('-'):
+ options = ' -x' + options.strip()[1:]
+ # else: punt, we can't do it, let the warning happen anyway
+ else:
+ options = ' -x'
+ executable = fix_jython_executable(executable, options)
+ hdr = "#!%(executable)s%(options)s\n" % locals()
+ return hdr
+
class WindowsScriptWriter(ScriptWriter):
@classmethod