install_headers.py 985 B

123456789101112131415161718192021222324252627
  1. from __future__ import division, absolute_import, print_function
  2. import os
  3. from distutils.command.install_headers import install_headers as old_install_headers
  4. class install_headers (old_install_headers):
  5. def run (self):
  6. headers = self.distribution.headers
  7. if not headers:
  8. return
  9. prefix = os.path.dirname(self.install_dir)
  10. for header in headers:
  11. if isinstance(header, tuple):
  12. # Kind of a hack, but I don't know where else to change this...
  13. if header[0] == 'numpy.core':
  14. header = ('numpy', header[1])
  15. if os.path.splitext(header[1])[1] == '.inc':
  16. continue
  17. d = os.path.join(*([prefix]+header[0].split('.')))
  18. header = header[1]
  19. else:
  20. d = self.install_dir
  21. self.mkpath(d)
  22. (out, _) = self.copy_file(header, d)
  23. self.outfiles.append(out)