Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/setuptools/command/install_scripts.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author | bcclaywell |
---|---|
date | Mon, 12 Oct 2015 17:43:33 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d67268158946 |
---|---|
1 from distutils import log | |
2 import distutils.command.install_scripts as orig | |
3 import os | |
4 | |
5 from pkg_resources import Distribution, PathMetadata, ensure_directory | |
6 | |
7 | |
8 class install_scripts(orig.install_scripts): | |
9 """Do normal script install, plus any egg_info wrapper scripts""" | |
10 | |
11 def initialize_options(self): | |
12 orig.install_scripts.initialize_options(self) | |
13 self.no_ep = False | |
14 | |
15 def run(self): | |
16 import setuptools.command.easy_install as ei | |
17 | |
18 self.run_command("egg_info") | |
19 if self.distribution.scripts: | |
20 orig.install_scripts.run(self) # run first to set up self.outfiles | |
21 else: | |
22 self.outfiles = [] | |
23 if self.no_ep: | |
24 # don't install entry point scripts into .egg file! | |
25 return | |
26 | |
27 ei_cmd = self.get_finalized_command("egg_info") | |
28 dist = Distribution( | |
29 ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info), | |
30 ei_cmd.egg_name, ei_cmd.egg_version, | |
31 ) | |
32 bs_cmd = self.get_finalized_command('build_scripts') | |
33 exec_param = getattr(bs_cmd, 'executable', None) | |
34 bw_cmd = self.get_finalized_command("bdist_wininst") | |
35 is_wininst = getattr(bw_cmd, '_is_running', False) | |
36 writer = ei.ScriptWriter | |
37 if is_wininst: | |
38 exec_param = "python.exe" | |
39 writer = ei.WindowsScriptWriter | |
40 # resolve the writer to the environment | |
41 writer = writer.best() | |
42 cmd = writer.command_spec_class.best().from_param(exec_param) | |
43 for args in writer.get_args(dist, cmd.as_header()): | |
44 self.write_script(*args) | |
45 | |
46 def write_script(self, script_name, contents, mode="t", *ignored): | |
47 """Write an executable file to the scripts directory""" | |
48 from setuptools.command.easy_install import chmod, current_umask | |
49 | |
50 log.info("Installing %s script to %s", script_name, self.install_dir) | |
51 target = os.path.join(self.install_dir, script_name) | |
52 self.outfiles.append(target) | |
53 | |
54 mask = current_umask() | |
55 if not self.dry_run: | |
56 ensure_directory(target) | |
57 f = open(target, "w" + mode) | |
58 f.write(contents) | |
59 f.close() | |
60 chmod(target, 0o777 - mask) |