1 """distutils.command.install_scripts
3 Implements the Distutils 'install_scripts' command, for installing
6 # contributed by Bastian Kleineidam
11 from distutils
.core
import Command
12 from distutils
import log
13 from stat
import ST_MODE
15 class install_scripts (Command
):
17 description
= "install scripts (Python or otherwise)"
20 ('install-dir=', 'd', "directory to install scripts to"),
21 ('build-dir=','b', "build directory (where to install from)"),
22 ('force', 'f', "force installation (overwrite existing files)"),
23 ('skip-build', None, "skip the build steps"),
26 boolean_options
= ['force', 'skip-build']
29 def initialize_options (self
):
30 self
.install_dir
= None
33 self
.skip_build
= None
35 def finalize_options (self
):
36 self
.set_undefined_options('build', ('build_scripts', 'build_dir'))
37 self
.set_undefined_options('install',
38 ('install_scripts', 'install_dir'),
40 ('skip_build', 'skip_build'),
44 if not self
.skip_build
:
45 self
.run_command('build_scripts')
46 self
.outfiles
= self
.copy_tree(self
.build_dir
, self
.install_dir
)
47 if os
.name
== 'posix':
48 # Set the executable bits (owner, group, and world) on
49 # all the scripts we just installed.
50 for file in self
.get_outputs():
52 log
.info("changing mode of %s", file)
54 mode
= ((os
.stat(file)[ST_MODE
]) |
0555) & 07777
55 log
.info("changing mode of %s to %o", file, mode
)
58 def get_inputs (self
):
59 return self
.distribution
.scripts
or []
61 def get_outputs(self
):
62 return self
.outfiles
or []
64 # class install_scripts