ยปCore Development>Code coverage>Lib/distutils/command/install_scripts.py

Python code coverage for Lib/distutils/command/install_scripts.py

#countcontent
1n/a"""distutils.command.install_scripts
2n/a
3n/aImplements the Distutils 'install_scripts' command, for installing
4n/aPython scripts."""
5n/a
6n/a# contributed by Bastian Kleineidam
7n/a
8n/aimport os
9n/afrom distutils.core import Command
10n/afrom distutils import log
11n/afrom stat import ST_MODE
12n/a
13n/a
14n/aclass install_scripts(Command):
15n/a
16n/a description = "install scripts (Python or otherwise)"
17n/a
18n/a user_options = [
19n/a ('install-dir=', 'd', "directory to install scripts to"),
20n/a ('build-dir=','b', "build directory (where to install from)"),
21n/a ('force', 'f', "force installation (overwrite existing files)"),
22n/a ('skip-build', None, "skip the build steps"),
23n/a ]
24n/a
25n/a boolean_options = ['force', 'skip-build']
26n/a
27n/a def initialize_options(self):
28n/a self.install_dir = None
29n/a self.force = 0
30n/a self.build_dir = None
31n/a self.skip_build = None
32n/a
33n/a def finalize_options(self):
34n/a self.set_undefined_options('build', ('build_scripts', 'build_dir'))
35n/a self.set_undefined_options('install',
36n/a ('install_scripts', 'install_dir'),
37n/a ('force', 'force'),
38n/a ('skip_build', 'skip_build'),
39n/a )
40n/a
41n/a def run(self):
42n/a if not self.skip_build:
43n/a self.run_command('build_scripts')
44n/a self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
45n/a if os.name == 'posix':
46n/a # Set the executable bits (owner, group, and world) on
47n/a # all the scripts we just installed.
48n/a for file in self.get_outputs():
49n/a if self.dry_run:
50n/a log.info("changing mode of %s", file)
51n/a else:
52n/a mode = ((os.stat(file)[ST_MODE]) | 0o555) & 0o7777
53n/a log.info("changing mode of %s to %o", file, mode)
54n/a os.chmod(file, mode)
55n/a
56n/a def get_inputs(self):
57n/a return self.distribution.scripts or []
58n/a
59n/a def get_outputs(self):
60n/a return self.outfiles or []