1 """distutils.command.install_scripts
3 Implements the Distutils 'install_scripts' command, for installing
6 # contributed by Bastian Kleineidam
9 from ..core import Command
10 from distutils._log import log
11 from stat import ST_MODE
14 class install_scripts(Command):
16 description = "install scripts (Python or otherwise)"
19 ('install-dir=', 'd', "directory to install scripts to"),
20 ('build-dir=', 'b', "build directory (where to install from)"),
21 ('force', 'f', "force installation (overwrite existing files)"),
22 ('skip-build', None, "skip the build steps"),
25 boolean_options = ['force', 'skip-build']
27 def initialize_options(self):
28 self.install_dir = None
31 self.skip_build = None
33 def finalize_options(self):
34 self.set_undefined_options('build', ('build_scripts', 'build_dir'))
35 self.set_undefined_options(
37 ('install_scripts', 'install_dir'),
39 ('skip_build', 'skip_build'),
43 if not self.skip_build:
44 self.run_command('build_scripts')
45 self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
46 if os.name == 'posix':
47 # Set the executable bits (owner, group, and world) on
48 # all the scripts we just installed.
49 for file in self.get_outputs():
51 log.info("changing mode of %s", file)
53 mode = ((os.stat(file)[ST_MODE]) | 0o555) & 0o7777
54 log.info("changing mode of %s to %o", file, mode)
58 return self.distribution.scripts or []
60 def get_outputs(self):
61 return self.outfiles or []