setup.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # call with
  2. # sage -python setup.py build_ext --inplace
  3. import os, sys, platform
  4. try:
  5. CILK_ROOT = os.environ['CILK_ROOT']
  6. except KeyError:
  7. raise EnvironmentError, "Please define the CILK_ROOT environment variable !"
  8. # setup the gcc/cilk compiler
  9. if 'CC' not in os.environ:
  10. os.environ['CC'] = os.path.join(CILK_ROOT, 'bin', 'g++-5')
  11. from distutils.core import setup
  12. from distutils.extension import Extension
  13. from Cython.Distutils import build_ext
  14. from distutils.extension import Extension
  15. from sage.env import *
  16. #SAGE_INC = os.path.join(SAGE_LOCAL, 'include')
  17. #SAGE_C = os.path.join(SAGE_SRC, 'c_lib', 'include')
  18. #SAGE_DEV = os.path.join(SAGE_ROOT, 'src')
  19. if platform.system()=="Darwin":
  20. MARCH='-march=corei7'
  21. MTUNE='-march=corei7'
  22. CILK_LIB = os.path.join(CILK_ROOT, 'lib')
  23. else:
  24. MARCH='-march=native'
  25. MTUNE='-march=native'
  26. CILK_LIB = os.path.join(CILK_ROOT, 'lib64')
  27. import Cython.Compiler.Options
  28. Cython.Compiler.Options.annotate = True
  29. sage_include = sage_include_directories()
  30. packs = [x for x in sage_include if x.endswith('site-packages')][0]
  31. sage_include.append(os.path.join(packs, 'cysignals'))
  32. #sage_include+=sys.path
  33. #sage_include.append('/home/data/Sage-Install/sage-7.2.beta2/local/lib/python2.7/site-packages/cysignals/')
  34. setup(
  35. cmdclass = {'build_ext': build_ext},
  36. ext_modules = [
  37. Extension('numeric_monoid',
  38. sources = ['numeric_monoid.pyx', 'monoid.cpp', 'treewalk.cpp'],
  39. depends = ['numeric_monoid.pxd', 'monoid.hpp', 'treewalk.hpp'],
  40. language="c++",
  41. extra_compile_args = ['-std=c++11', '-O3',
  42. MARCH, MTUNE,
  43. '-fcilkplus'],
  44. define_macros = [('NDEBUG', '1'), ('MAX_GENUS','86')],
  45. include_dirs = sage_include, # [SAGE_C,SAGE_DEV],
  46. library_dirs = [CILK_LIB],
  47. runtime_library_dirs = [CILK_LIB],
  48. libraries = ['cilkrts'],
  49. ),
  50. ])