annotate Lib/distutils/command/install_headers.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 d296e6bb17e5
children f465d6692bde
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12776
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
1 """distutils.command.install_headers
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
2
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
3 Implements the Distutils 'install_headers' command, to install C/C++ header
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
4 files to the Python include directory."""
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
5
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
6 # created 2000/05/26, Greg Ward
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
7
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
8 __revision__ = "$Id$"
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
9
12981
9569c5625765 Build the 'outfiles' list so 'get_outputs()' has something to return.
Greg Ward <gward@python.net>
parents: 12776
diff changeset
10 import os
12776
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
11 from distutils.core import Command
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
12
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
13
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
14 class install_headers (Command):
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
15
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
16 description = "install C/C++ header files"
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
17
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
18 user_options = [('install-dir=', 'd',
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
19 "directory to install header files to"),
14540
35ae8dff8ed0 Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents: 13413
diff changeset
20 ('force', 'f',
35ae8dff8ed0 Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents: 13413
diff changeset
21 "force installation (overwrite existing files)"),
12776
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
22 ]
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
23
14829
b1f220f636ed Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents: 14540
diff changeset
24 boolean_options = ['force']
12776
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
25
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
26 def initialize_options (self):
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
27 self.install_dir = None
14540
35ae8dff8ed0 Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents: 13413
diff changeset
28 self.force = 0
13413
7fea4a1af090 fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 12982
diff changeset
29 self.outfiles = []
12776
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
30
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
31 def finalize_options (self):
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
32 self.set_undefined_options('install',
14540
35ae8dff8ed0 Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents: 13413
diff changeset
33 ('install_headers', 'install_dir'),
35ae8dff8ed0 Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents: 13413
diff changeset
34 ('force', 'force'))
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 14945
diff changeset
35
12776
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
36
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
37 def run (self):
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
38 headers = self.distribution.headers
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
39 if not headers:
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
40 return
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
41
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
42 self.mkpath(self.install_dir)
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
43 for header in headers:
14945
a59600a975d1 Expect a tuple (dest_name, copied) from 'copy_file()'.
Greg Ward <gward@python.net>
parents: 14829
diff changeset
44 (out, _) = self.copy_file(header, self.install_dir)
12981
9569c5625765 Build the 'outfiles' list so 'get_outputs()' has something to return.
Greg Ward <gward@python.net>
parents: 12776
diff changeset
45 self.outfiles.append(out)
12776
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
46
12981
9569c5625765 Build the 'outfiles' list so 'get_outputs()' has something to return.
Greg Ward <gward@python.net>
parents: 12776
diff changeset
47 def get_inputs (self):
9569c5625765 Build the 'outfiles' list so 'get_outputs()' has something to return.
Greg Ward <gward@python.net>
parents: 12776
diff changeset
48 return self.distribution.headers or []
9569c5625765 Build the 'outfiles' list so 'get_outputs()' has something to return.
Greg Ward <gward@python.net>
parents: 12776
diff changeset
49
9569c5625765 Build the 'outfiles' list so 'get_outputs()' has something to return.
Greg Ward <gward@python.net>
parents: 12776
diff changeset
50 def get_outputs (self):
9569c5625765 Build the 'outfiles' list so 'get_outputs()' has something to return.
Greg Ward <gward@python.net>
parents: 12776
diff changeset
51 return self.outfiles
12776
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
52
342947f2fb51 Added 'install_headers' command to install C/C++ header files.
Greg Ward <gward@python.net>
parents:
diff changeset
53 # class install_headers