You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB

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