/Lib/distutils/command/install_headers.py

http://unladen-swallow.googlecode.com/ · Python · 52 lines · 50 code · 0 blank · 2 comment · 0 complexity · d799a566e19d66674b3a9553b94d69c0 MD5 · raw file

  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. # This module should be kept compatible with Python 2.1.
  5. __revision__ = "$Id: install_headers.py 61000 2008-02-23 17:40:11Z christian.heimes $"
  6. from distutils.core import Command
  7. class install_headers (Command):
  8. description = "install C/C++ header files"
  9. user_options = [('install-dir=', 'd',
  10. "directory to install header files to"),
  11. ('force', 'f',
  12. "force installation (overwrite existing files)"),
  13. ]
  14. boolean_options = ['force']
  15. def initialize_options (self):
  16. self.install_dir = None
  17. self.force = 0
  18. self.outfiles = []
  19. def finalize_options (self):
  20. self.set_undefined_options('install',
  21. ('install_headers', 'install_dir'),
  22. ('force', 'force'))
  23. def run (self):
  24. headers = self.distribution.headers
  25. if not headers:
  26. return
  27. self.mkpath(self.install_dir)
  28. for header in headers:
  29. (out, _) = self.copy_file(header, self.install_dir)
  30. self.outfiles.append(out)
  31. def get_inputs (self):
  32. return self.distribution.headers or []
  33. def get_outputs (self):
  34. return self.outfiles
  35. # class install_headers