diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-05-19 02:47:41 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-05-19 02:47:41 -0400 |
commit | 289b359721b9a717984c5200d7d5adbfccc8da20 (patch) | |
tree | d9afa01eaa438ec75c8df75df8ae9638dd56feb4 | |
parent | b5d83f95a99b5e52d36fac68735e84ee73d364fd (diff) | |
download | external_python_setuptools-289b359721b9a717984c5200d7d5adbfccc8da20.tar.gz external_python_setuptools-289b359721b9a717984c5200d7d5adbfccc8da20.tar.bz2 external_python_setuptools-289b359721b9a717984c5200d7d5adbfccc8da20.zip |
Extract get_win_launcher function
--HG--
branch : distribute
extra : rebase_source : 14dbef22dbc8376cc3632ce53be0d61b7976b889
-rw-r--r-- | CHANGES.txt | 7 | ||||
-rwxr-xr-x | setuptools/command/easy_install.py | 31 |
2 files changed, 29 insertions, 9 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 2e0b747c..864edfba 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,6 +3,13 @@ CHANGES ======= ------ +0.6.41 +------ + +* Added a new function ``easy_install.get_win_launcher`` which may be used by + third-party libraries such as buildout to get a suitable script launcher. + +------ 0.6.40 ------ diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 10a8f272..df6107d7 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1833,26 +1833,22 @@ def get_script_args(dist, executable=sys_executable, wininst=False): if sys.platform=='win32' or wininst: # On Windows/wininst, add a .py extension and an .exe launcher if group=='gui_scripts': - ext, launcher = '-script.pyw', 'gui.exe' + launcher_type = 'gui' + ext = '-script.pyw' old = ['.pyw'] new_header = re.sub('(?i)python.exe','pythonw.exe',header) else: - ext, launcher = '-script.py', 'cli.exe' + launcher_type = 'cli' + ext = '-script.py' old = ['.py','.pyc','.pyo'] new_header = re.sub('(?i)pythonw.exe','python.exe',header) - if platform.machine().lower()=='arm': - launcher = launcher.replace(".", "-arm.") - if is_64bit(): - launcher = launcher.replace(".", "-64.") - else: - launcher = launcher.replace(".", "-32.") if os.path.exists(new_header[2:-1]) 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', resource_string('setuptools', launcher), + name+'.exe', get_win_launcher(launcher_type), 'b' # write in binary mode ) if not is_64bit(): @@ -1868,6 +1864,23 @@ def get_script_args(dist, executable=sys_executable, wininst=False): # just write the stub with no extension. yield (name, header+script_text) +def get_win_launcher(type): + """ + Load the Windows launcher (executable) suitable for launching a script. + + `type` should be either 'cli' or 'gui' + + Returns the executable as a byte string. + """ + launcher_fn = '%s.exe' % type + if platform.machine().lower()=='arm': + launcher_fn = launcher_fn.replace(".", "-arm.") + if is_64bit(): + launcher_fn = launcher_fn.replace(".", "-64.") + else: + launcher_fn = launcher_fn.replace(".", "-32.") + return resource_string('setuptools', launcher_fn) + def load_launcher_manifest(name): manifest = pkg_resources.resource_string(__name__, 'launcher manifest.xml') if sys.version_info[0] < 3: |