]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/blob - zfec/setuptools-0.6c15dev.egg/setuptools/command/install_scripts.py
79fa375fbdf11acab09497e7fa1a3c53d43ef6a5
[tahoe-lafs/zfec.git] / zfec / setuptools-0.6c15dev.egg / setuptools / command / install_scripts.py
1 from distutils.command.install_scripts import install_scripts \
2      as _install_scripts
3 from easy_install import get_script_args, sys_executable, chmod
4 from pkg_resources import Distribution, PathMetadata, ensure_directory
5 import os
6 from distutils import log
7
8 class install_scripts(_install_scripts):
9     """Do normal script install, plus any egg_info wrapper scripts"""
10
11     def initialize_options(self):
12         _install_scripts.initialize_options(self)
13         self.no_ep = False
14
15     def run(self):
16         self.run_command("egg_info")
17         if self.distribution.scripts:
18             _install_scripts.run(self)  # run first to set up self.outfiles
19         else:
20             self.outfiles = []
21         if self.no_ep:
22             # don't install entry point scripts into .egg file!
23             return
24
25         ei_cmd = self.get_finalized_command("egg_info")
26         dist = Distribution(
27             ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
28             ei_cmd.egg_name, ei_cmd.egg_version,
29         )
30         bs_cmd = self.get_finalized_command('build_scripts')
31         executable = getattr(bs_cmd,'executable',sys_executable)
32         is_wininst = getattr(
33             self.get_finalized_command("bdist_wininst"), '_is_running', False
34         )
35         for args in get_script_args(dist, executable, is_wininst):
36             self.write_script(*args)
37
38
39
40
41
42     def write_script(self, script_name, contents, mode="t", *ignored):
43         """Write an executable file to the scripts directory"""
44         log.info("Installing %s script to %s", script_name, self.install_dir)
45         target = os.path.join(self.install_dir, script_name)
46         self.outfiles.append(target)
47
48         if not self.dry_run:
49             ensure_directory(target)
50             f = open(target,"w"+mode)
51             f.write(contents)
52             f.close()
53             chmod(target,0755)
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82