1 from setuptools
import setup
, dist
#, Extension
2 from distutils
.extension
import Extension
4 # We need to have numpy and cython imported before calling cythonize
5 # cf. https://luminousmen.com/post/resolve-cython-and-numpy-dependencies
6 # and https://github.com/pypa/pip/issues/5761
8 dist
.Distribution().fetch_build_eggs(['Cython>=0.28', 'numpy>=1.2'])
10 from Cython
.Build
import cythonize
, build_ext
12 numpy_includes
=numpy
.get_include()
14 # setuptools DWIM monkey-patch madness
15 # http://mail.python.org/pipermail/distutils-sig/2007-September/thread.html#8204
17 #if 'setuptools.extension' in sys.modules:
18 # m = sys.modules['setuptools.extension']
19 # m.Extension.__dict__ = m._Extension.__dict__
21 # TODO CHECK THIS OUT http://stackoverflow.com/questions/4056657/what-is-the-easiest-way-to-make-an-optional-c-extension-for-a-python-package
22 # AND THIS https://groups.google.com/forum/#!topic/cython-users/GAAPYb2X304
23 # also this: https://docs.python.org/2/extending/building.html
26 #print("You might want to add additional library path to LD_LIBRARY_PATH (especially if you are not using"
27 # " GNU GSL in your system library path) and if import fails. ")
28 #if("LD_LIBRARY_PATH" in os.environ):
29 # print(os.environ['LD_LIBRARY_PATH'].split(':'))
77 #'qpms/hexpoints_c.pyx',
78 'qpms/gaunt.c',#'qpms/gaunt.h','qpms/vectors.h','qpms/translations.h',
79 # FIXME http://stackoverflow.com/questions/4259170/python-setup-script-extensions-how-do-you-include-a-h-file
80 'qpms/translations.c',
84 'qpms/vswf.c', # FIXME many things from vswf.c are not required by this module, but they have many dependencies (following in this list); maybe I want to move all the "basespec stuff"
95 common_libs
=['qpms', 'gsl', 'lapacke', 'blas', 'pthread',]
97 cycommon
= Extension('qpms.cycommon',
98 sources
= ['qpms/cycommon.pyx'],
99 #extra_link_args=['qpms/libqpms.a'],
100 libraries
= common_libs
,
101 include_dirs
= [numpy_includes
],
103 cytmatrices
= Extension('qpms.cytmatrices',
104 sources
= ['qpms/cytmatrices.pyx'],
105 #extra_link_args=['qpms/libqpms.a', 'amos/libamos.a'],
106 libraries
= common_libs
,
107 include_dirs
= [numpy_includes
],
109 cywaves
= Extension('qpms.cywaves',
110 sources
= ['qpms/cywaves.pyx'],
111 libraries
= common_libs
,
112 include_dirs
= [numpy_includes
],
114 cytranslations
= Extension('qpms.cytranslations',
115 sources
= ['qpms/cytranslations.pyx',
116 'qpms/translations_python.c',
118 extra_compile_args
=['-std=c99',
119 '-DQPMS_COMPILE_PYTHON_EXTENSIONS', # This is needed to enable it in translations.h
121 #extra_link_args=['qpms/libqpms.a', 'amos/libamos.a'],
122 libraries
= common_libs
,
123 include_dirs
= [numpy_includes
],
125 cybspec
= Extension('qpms.cybspec',
126 sources
= ['qpms/cybspec.pyx'],
127 #extra_link_args=['qpms/libqpms.a'],
128 libraries
= common_libs
,
129 include_dirs
= [numpy_includes
],
131 cymaterials
= Extension('qpms.cymaterials',
132 sources
= ['qpms/cymaterials.pyx'],
133 #extra_link_args=['qpms/libqpms.a'],
134 libraries
= common_libs
,
135 include_dirs
= [numpy_includes
],
137 cyquaternions
= Extension('qpms.cyquaternions',
138 sources
= ['qpms/cyquaternions.pyx'],
139 #extra_link_args=['amos/libamos.a', 'qpms/libqpms.a'],
140 libraries
= common_libs
,
141 include_dirs
= [numpy_includes
],
143 cyewaldtest
= Extension('qpms.cyewaldtest',
144 sources
= ['qpms/cyewaldtest.pyx'],
145 libraries
= common_libs
,
146 include_dirs
= [numpy_includes
],
149 qpms_c
= Extension('qpms.qpms_c',
150 sources
= ['qpms/qpms_c.pyx',],
151 libraries
= common_libs
,
152 include_dirs
=['amos', 'qpms', numpy_includes
],
153 extra_link_args
=['-fopenmp'],
154 extra_compile_args
=['-fopenmp'],
160 # libraries = [('amos', {'sources': amos_sources} )],
161 setup_requires
=['cython>=0.28','numpy>=1.2','setuptools>=18.0'],
162 install_requires
=['cython>=0.28',
163 #'quaternion','spherical_functions',
164 'scipy>=0.18.0', 'sympy>=1.2', 'numpy>=1.2'],
165 #dependency_links=['https://github.com/moble/quaternion/archive/v2.0.tar.gz','https://github.com/moble/spherical_functions/archive/master.zip'],
166 ext_modules
=cythonize([qpms_c
, cywaves
, cytranslations
, cytmatrices
, cycommon
, cyquaternions
, cybspec
, cymaterials
, cyewaldtest
], include_path
=['qpms', 'amos'], gdb_debug
=True),
167 cmdclass
= {'build_ext': build_ext
},