aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsetuptools/command/easy_install.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 5c50dbe2..6ec96564 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -1920,13 +1920,9 @@ class ScriptWriter(object):
"""Create a #! line, getting options (if any) from script_text"""
if executable is None:
executable = nt_quote_arg(sys_executable)
- first = (script_text + '\n').splitlines()[0]
- match = _first_line_re().match(first)
- options = ''
- if match:
- options = match.group(1) or ''
- if options:
- options = ' ' + options
+
+ options = cls._extract_options(script_text)
+
hdr = "#!%(executable)s%(options)s\n" % locals()
if not isascii(hdr):
# Non-ascii path to sys.executable, use -x to prevent warnings
@@ -1940,6 +1936,20 @@ class ScriptWriter(object):
hdr = "#!%(executable)s%(options)s\n" % locals()
return hdr
+ @classmethod
+ def _extract_options(cls, orig_script):
+ """
+ Extract any options from the first line of the script.
+ """
+ first = (orig_script + '\n').splitlines()[0]
+ match = _first_line_re().match(first)
+ options = ''
+ if match:
+ options = match.group(1) or ''
+ if options:
+ options = ' ' + options
+ return options
+
class WindowsScriptWriter(ScriptWriter):
@classmethod