install_headers.py 1.2 KB

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