• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""distutils.command.install_headers
2
3Implements the Distutils 'install_headers' command, to install C/C++ header
4files to the Python include directory."""
5
6from distutils.core import Command
7
8
9# XXX force is never used
10class install_headers(Command):
11
12    description = "install C/C++ header files"
13
14    user_options = [('install-dir=', 'd',
15                     "directory to install header files to"),
16                    ('force', 'f',
17                     "force installation (overwrite existing files)"),
18                   ]
19
20    boolean_options = ['force']
21
22    def initialize_options(self):
23        self.install_dir = None
24        self.force = 0
25        self.outfiles = []
26
27    def finalize_options(self):
28        self.set_undefined_options('install',
29                                   ('install_headers', 'install_dir'),
30                                   ('force', 'force'))
31
32
33    def run(self):
34        headers = self.distribution.headers
35        if not headers:
36            return
37
38        self.mkpath(self.install_dir)
39        for header in headers:
40            (out, _) = self.copy_file(header, self.install_dir)
41            self.outfiles.append(out)
42
43    def get_inputs(self):
44        return self.distribution.headers or []
45
46    def get_outputs(self):
47        return self.outfiles
48