setup.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from __future__ import division, print_function
  2. import os
  3. import sys
  4. def configuration(parent_package='', top_path=None):
  5. from numpy.distutils.misc_util import Configuration
  6. from numpy.distutils.system_info import get_info
  7. config = Configuration('linalg', parent_package, top_path)
  8. config.add_data_dir('tests')
  9. # Configure lapack_lite
  10. src_dir = 'lapack_lite'
  11. lapack_lite_src = [
  12. os.path.join(src_dir, 'python_xerbla.c'),
  13. os.path.join(src_dir, 'f2c_z_lapack.c'),
  14. os.path.join(src_dir, 'f2c_c_lapack.c'),
  15. os.path.join(src_dir, 'f2c_d_lapack.c'),
  16. os.path.join(src_dir, 'f2c_s_lapack.c'),
  17. os.path.join(src_dir, 'f2c_lapack.c'),
  18. os.path.join(src_dir, 'f2c_blas.c'),
  19. os.path.join(src_dir, 'f2c_config.c'),
  20. os.path.join(src_dir, 'f2c.c'),
  21. ]
  22. all_sources = config.paths(lapack_lite_src)
  23. lapack_info = get_info('lapack_opt', 0) # and {}
  24. def get_lapack_lite_sources(ext, build_dir):
  25. if not lapack_info:
  26. print("### Warning: Using unoptimized lapack ###")
  27. return all_sources
  28. else:
  29. if sys.platform == 'win32':
  30. print("### Warning: python_xerbla.c is disabled ###")
  31. return []
  32. return [all_sources[0]]
  33. config.add_extension(
  34. 'lapack_lite',
  35. sources=['lapack_litemodule.c', get_lapack_lite_sources],
  36. depends=['lapack_lite/f2c.h'],
  37. extra_info=lapack_info,
  38. )
  39. # umath_linalg module
  40. config.add_extension(
  41. '_umath_linalg',
  42. sources=['umath_linalg.c.src', get_lapack_lite_sources],
  43. depends=['lapack_lite/f2c.h'],
  44. extra_info=lapack_info,
  45. libraries=['npymath'],
  46. )
  47. return config
  48. if __name__ == '__main__':
  49. from numpy.distutils.core import setup
  50. setup(configuration=configuration)