annotate Lib/distutils/command/install_scripts.py @ 74135:9c19df6c8ea0 3.2

News entry for Issue12798
author Senthil Kumaran <senthil@uthcode.com>
date Fri, 23 Dec 2011 11:11:21 +0800
parents 3e26c9033306
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12682
7c89ee40730f Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12678
diff changeset
1 """distutils.command.install_scripts
7c89ee40730f Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12678
diff changeset
2
7c89ee40730f Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12678
diff changeset
3 Implements the Distutils 'install_scripts' command, for installing
7c89ee40730f Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12678
diff changeset
4 Python scripts."""
7c89ee40730f Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12678
diff changeset
5
7c89ee40730f Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12678
diff changeset
6 # contributed by Bastian Kleineidam
7c89ee40730f Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12678
diff changeset
7
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
8 import os
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
9 from distutils.core import Command
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21852
diff changeset
10 from distutils import log
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
11 from stat import ST_MODE
12675
de435a59a4d5 Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff changeset
12
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 42084
diff changeset
13
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 42084
diff changeset
14 class install_scripts(Command):
12675
de435a59a4d5 Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff changeset
15
12778
0263a99d0eb2 Tweaked description, help text.
Greg Ward <gward@python.net>
parents: 12744
diff changeset
16 description = "install scripts (Python or otherwise)"
12675
de435a59a4d5 Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff changeset
17
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
18 user_options = [
12778
0263a99d0eb2 Tweaked description, help text.
Greg Ward <gward@python.net>
parents: 12744
diff changeset
19 ('install-dir=', 'd', "directory to install scripts to"),
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
20 ('build-dir=','b', "build directory (where to install from)"),
14540
35ae8dff8ed0 Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents: 12783
diff changeset
21 ('force', 'f', "force installation (overwrite existing files)"),
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
22 ('skip-build', None, "skip the build steps"),
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
23 ]
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
24
14829
b1f220f636ed Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents: 14540
diff changeset
25 boolean_options = ['force', 'skip-build']
b1f220f636ed Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents: 14540
diff changeset
26
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 42084
diff changeset
27 def initialize_options(self):
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
28 self.install_dir = None
14540
35ae8dff8ed0 Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents: 12783
diff changeset
29 self.force = 0
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
30 self.build_dir = None
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
31 self.skip_build = None
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
32
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 42084
diff changeset
33 def finalize_options(self):
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
34 self.set_undefined_options('build', ('build_scripts', 'build_dir'))
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14829
diff changeset
35 self.set_undefined_options('install',
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14829
diff changeset
36 ('install_scripts', 'install_dir'),
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14829
diff changeset
37 ('force', 'force'),
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14829
diff changeset
38 ('skip_build', 'skip_build'),
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14829
diff changeset
39 )
12675
de435a59a4d5 Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff changeset
40
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 42084
diff changeset
41 def run(self):
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
42 if not self.skip_build:
12783
b91b35c1d4c0 Some far-reaching naming changes:
Greg Ward <gward@python.net>
parents: 12778
diff changeset
43 self.run_command('build_scripts')
14540
35ae8dff8ed0 Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents: 12783
diff changeset
44 self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
45 if os.name == 'posix':
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
46 # Set the executable bits (owner, group, and world) on
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
47 # all the scripts we just installed.
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
48 for file in self.get_outputs():
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
49 if self.dry_run:
23672
edc423940cd6 Fix bug in recent change to logging code.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23668
diff changeset
50 log.info("changing mode of %s", file)
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
51 else:
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 33965
diff changeset
52 mode = ((os.stat(file)[ST_MODE]) | 0o555) & 0o7777
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21852
diff changeset
53 log.info("changing mode of %s to %o", file, mode)
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
54 os.chmod(file, mode)
12675
de435a59a4d5 Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff changeset
55
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 42084
diff changeset
56 def get_inputs(self):
12702
58ad6196d81f Added 'get_inputs()' methods, needed by the "install" command's
Gregory P. Smith <greg@mad-scientist.com>
parents: 12682
diff changeset
57 return self.distribution.scripts or []
58ad6196d81f Added 'get_inputs()' methods, needed by the "install" command's
Gregory P. Smith <greg@mad-scientist.com>
parents: 12682
diff changeset
58
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
59 def get_outputs(self):
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
60 return self.outfiles or []