]> git.saurik.com Git - wxWidgets.git/blame - wxPython/distutils/command/install_scripts.py
Renamed the core namespace's submodules to have a leading underscore.
[wxWidgets.git] / wxPython / distutils / command / install_scripts.py
CommitLineData
1e4a197e
RD
1"""distutils.command.install_scripts
2
3Implements the Distutils 'install_scripts' command, for installing
4Python scripts."""
5
6# contributed by Bastian Kleineidam
7
8# This module should be kept compatible with Python 1.5.2.
9
10__revision__ = "$Id$"
11
12import os
13from distutils.core import Command
14from distutils import log
15from stat import ST_MODE
16
17class install_scripts (Command):
18
19 description = "install scripts (Python or otherwise)"
20
21 user_options = [
22 ('install-dir=', 'd', "directory to install scripts to"),
23 ('build-dir=','b', "build directory (where to install from)"),
24 ('force', 'f', "force installation (overwrite existing files)"),
25 ('skip-build', None, "skip the build steps"),
26 ]
27
28 boolean_options = ['force', 'skip-build']
29
30
31 def initialize_options (self):
32 self.install_dir = None
33 self.force = 0
34 self.build_dir = None
35 self.skip_build = None
36
37 def finalize_options (self):
38 self.set_undefined_options('build', ('build_scripts', 'build_dir'))
39 self.set_undefined_options('install',
40 ('install_scripts', 'install_dir'),
41 ('force', 'force'),
42 ('skip_build', 'skip_build'),
43 )
44
45 def run (self):
46 if not self.skip_build:
47 self.run_command('build_scripts')
48 self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
49 if os.name == 'posix':
50 # Set the executable bits (owner, group, and world) on
51 # all the scripts we just installed.
52 for file in self.get_outputs():
53 if self.dry_run:
54 log.info("changing mode of %s", file)
55 else:
56 mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777
57 log.info("changing mode of %s to %o", file, mode)
58 os.chmod(file, mode)
59
60 def get_inputs (self):
61 return self.distribution.scripts or []
62
63 def get_outputs(self):
64 return self.outfiles or []
65
66# class install_scripts