annotate Lib/distutils/command/install_scripts.py @ 25838:8540887bcec6 2.2

Backport of 2.183: Fix memory leak in add_subclass() found by NealN with valgrind.
author Guido van Rossum <guido@python.org>
date Fri, 18 Oct 2002 13:42:21 +0000
parents 09ab9ce1f52a
children 7d30585a5934 ca87119255eb
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
7c89ee40730f Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12678
diff changeset
8 __revision__ = "$Id$"
7c89ee40730f Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12678
diff changeset
9
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
10 import os
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
11 from distutils.core import Command
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
12 from stat import ST_MODE
12675
de435a59a4d5 Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff changeset
13
12778
0263a99d0eb2 Tweaked description, help text.
Greg Ward <gward@python.net>
parents: 12744
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
b1f220f636ed Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents: 14540
diff changeset
27
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
28 def initialize_options (self):
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
29 self.install_dir = None
14540
35ae8dff8ed0 Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents: 12783
diff changeset
30 self.force = 0
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
31 self.build_dir = None
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
32 self.skip_build = None
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
33
12675
de435a59a4d5 Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff changeset
34 def finalize_options (self):
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
35 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
36 self.set_undefined_options('install',
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14829
diff changeset
37 ('install_scripts', 'install_dir'),
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14829
diff changeset
38 ('force', 'force'),
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14829
diff changeset
39 ('skip_build', 'skip_build'),
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14829
diff changeset
40 )
12675
de435a59a4d5 Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff changeset
41
de435a59a4d5 Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff changeset
42 def run (self):
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
43 if not self.skip_build:
12783
b91b35c1d4c0 Some far-reaching naming changes:
Greg Ward <gward@python.net>
parents: 12778
diff changeset
44 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
45 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
46 if os.name == 'posix':
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
47 # Set the executable bits (owner, group, and world) on
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
48 # 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
49 for file in self.get_outputs():
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
50 if self.dry_run:
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
51 self.announce("changing mode of %s" % file)
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
52 else:
21990
09ab9ce1f52a backport akuchling's checkin of
Michael W. Hudson <mwh@python.net>
parents: 14948
diff changeset
53 mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
54 self.announce("changing mode of %s to %o" % (file, mode))
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
55 os.chmod(file, mode)
12675
de435a59a4d5 Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff changeset
56
12702
58ad6196d81f Added 'get_inputs()' methods, needed by the "install" command's
Gregory P. Smith <greg@mad-scientist.com>
parents: 12682
diff changeset
57 def get_inputs (self):
58ad6196d81f Added 'get_inputs()' methods, needed by the "install" command's
Gregory P. Smith <greg@mad-scientist.com>
parents: 12682
diff changeset
58 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
59
12744
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
60 def get_outputs(self):
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
61 return self.outfiles or []
eeafab8c925b Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents: 12702
diff changeset
62
12678
875e677236a7 Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12675
diff changeset
63 # class install_scripts