setup.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from __future__ import division, print_function, absolute_import
  2. import os
  3. import sys
  4. import subprocess
  5. def configuration(parent_package='',top_path=None):
  6. from numpy.distutils.misc_util import Configuration
  7. config = Configuration('sparse',parent_package,top_path)
  8. config.add_data_dir('tests')
  9. config.add_subpackage('linalg')
  10. config.add_subpackage('csgraph')
  11. config.add_extension('_csparsetools',
  12. sources=['_csparsetools.c'])
  13. def get_sparsetools_sources(ext, build_dir):
  14. # Defer generation of source files
  15. subprocess.check_call([sys.executable,
  16. os.path.join(os.path.dirname(__file__),
  17. 'generate_sparsetools.py'),
  18. '--no-force'])
  19. return []
  20. depends = ['sparsetools_impl.h',
  21. 'bsr_impl.h',
  22. 'csc_impl.h',
  23. 'csr_impl.h',
  24. 'other_impl.h',
  25. 'bool_ops.h',
  26. 'bsr.h',
  27. 'complex_ops.h',
  28. 'coo.h',
  29. 'csc.h',
  30. 'csgraph.h',
  31. 'csr.h',
  32. 'dense.h',
  33. 'dia.h',
  34. 'py3k.h',
  35. 'sparsetools.h',
  36. 'util.h']
  37. depends = [os.path.join('sparsetools', hdr) for hdr in depends],
  38. config.add_extension('_sparsetools',
  39. define_macros=[('__STDC_FORMAT_MACROS', 1)],
  40. depends=depends,
  41. include_dirs=['sparsetools'],
  42. sources=[os.path.join('sparsetools', 'sparsetools.cxx'),
  43. os.path.join('sparsetools', 'csr.cxx'),
  44. os.path.join('sparsetools', 'csc.cxx'),
  45. os.path.join('sparsetools', 'bsr.cxx'),
  46. os.path.join('sparsetools', 'other.cxx'),
  47. get_sparsetools_sources]
  48. )
  49. return config
  50. if __name__ == '__main__':
  51. from numpy.distutils.core import setup
  52. setup(**configuration(top_path='').todict())