Fixed #1885: --formats=tar,gztar was not working properly in the sdist command
[python.git] / Lib / distutils / command / install_scripts.py
blob29cd9e7a0e394ec18ca4d8811cbf424454ce4009
1 """distutils.command.install_scripts
3 Implements the Distutils 'install_scripts' command, for installing
4 Python scripts."""
6 # contributed by Bastian Kleineidam
8 __revision__ = "$Id$"
10 import os
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)"
19 user_options = [
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
31 self.force = 0
32 self.build_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'),
39 ('force', 'force'),
40 ('skip_build', 'skip_build'),
43 def run (self):
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():
51 if self.dry_run:
52 log.info("changing mode of %s", file)
53 else:
54 mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777
55 log.info("changing mode of %s to %o", file, mode)
56 os.chmod(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