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