diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-08-05 23:04:36 +0200 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-08-05 23:04:36 +0200 |
commit | c1d0c2734b87687777adf584c2e2a9a457de3307 (patch) | |
tree | 0dd98082e1901eab8f46d8dce2d3f2499653f825 | |
parent | 46196e8239a9a8f523774f7d48bdf3b810bd083b (diff) | |
download | external_python_setuptools-c1d0c2734b87687777adf584c2e2a9a457de3307.tar.gz external_python_setuptools-c1d0c2734b87687777adf584c2e2a9a457de3307.tar.bz2 external_python_setuptools-c1d0c2734b87687777adf584c2e2a9a457de3307.zip |
Moved get_script_args into a ScriptWriter class method
--HG--
extra : rebase_source : 2acd6e7c81e54fa495f8b0eaf667b77f40c6495a
-rwxr-xr-x | setuptools/command/easy_install.py | 84 |
1 files changed, 44 insertions, 40 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index e667d0a3..49bf20c3 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1794,47 +1794,51 @@ class ScriptWriter(object): " )\n" ) -def get_script_args(dist, executable=sys_executable, wininst=False): - """Yield write_script() argument tuples for a distribution's entrypoints""" - spec = str(dist.as_requirement()) - header = get_script_header("", executable, wininst) - for type_ in 'console', 'gui': - group = type_ + '_scripts' - for name, ep in dist.get_entry_map(group).items(): - script_text = ScriptWriter.template % locals() - if sys.platform=='win32' or wininst: - # On Windows/wininst, add a .py extension and an .exe launcher - if type_=='gui': - launcher_type = 'gui' - ext = '-script.pyw' - old = ['.pyw'] - new_header = re.sub('(?i)python.exe','pythonw.exe',header) - else: - launcher_type = 'cli' - ext = '-script.py' - old = ['.py','.pyc','.pyo'] - new_header = re.sub('(?i)pythonw.exe','python.exe',header) - if os.path.exists(new_header[2:-1].strip('"')) or sys.platform!='win32': - hdr = new_header + @classmethod + def get_script_args(cls, dist, executable=sys_executable, wininst=False): + """Yield write_script() argument tuples for a distribution's entrypoints""" + spec = str(dist.as_requirement()) + header = get_script_header("", executable, wininst) + for type_ in 'console', 'gui': + group = type_ + '_scripts' + for name, ep in dist.get_entry_map(group).items(): + script_text = cls.template % locals() + if sys.platform=='win32' or wininst: + # On Windows/wininst, add a .py extension and an .exe launcher + if type_=='gui': + launcher_type = 'gui' + ext = '-script.pyw' + old = ['.pyw'] + new_header = re.sub('(?i)python.exe','pythonw.exe',header) + else: + launcher_type = 'cli' + ext = '-script.py' + old = ['.py','.pyc','.pyo'] + new_header = re.sub('(?i)pythonw.exe','python.exe',header) + if os.path.exists(new_header[2:-1].strip('"')) or sys.platform!='win32': + hdr = new_header + else: + hdr = header + yield (name+ext, hdr+script_text, 't', [name+x for x in old]) + yield ( + name+'.exe', get_win_launcher(launcher_type), + 'b' # write in binary mode + ) + if not is_64bit(): + # install a manifest for the launcher to prevent Windows + # from detecting it as an installer (which it will for + # launchers like easy_install.exe). Consider only + # adding a manifest for launchers detected as installers. + # See Distribute #143 for details. + m_name = name + '.exe.manifest' + yield (m_name, load_launcher_manifest(name), 't') else: - hdr = header - yield (name+ext, hdr+script_text, 't', [name+x for x in old]) - yield ( - name+'.exe', get_win_launcher(launcher_type), - 'b' # write in binary mode - ) - if not is_64bit(): - # install a manifest for the launcher to prevent Windows - # from detecting it as an installer (which it will for - # launchers like easy_install.exe). Consider only - # adding a manifest for launchers detected as installers. - # See Distribute #143 for details. - m_name = name + '.exe.manifest' - yield (m_name, load_launcher_manifest(name), 't') - else: - # On other platforms, we assume the right thing to do is to - # just write the stub with no extension. - yield (name, header+script_text) + # On other platforms, we assume the right thing to do is to + # just write the stub with no extension. + yield (name, header+script_text) + +# for backward-compatibility +get_script_args = ScriptWriter.get_script_args def get_win_launcher(type): """ |