install_headers.py 1.3 KB

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