diff --git a/setup.py b/setup.py index 29fd31f..6291afd 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,16 @@ -from setuptools import setup#, Extension -from Cython.Build import cythonize, build_ext +from setuptools import setup, dist#, Extension from distutils.extension import Extension + +# We need to have numpy and cython imported before calling cythonize +# cf. https://luminousmen.com/post/resolve-cython-and-numpy-dependencies +# and https://github.com/pypa/pip/issues/5761 + +dist.Distribution().fetch_build_eggs(['Cython>=0.28', 'numpy>=1.2']) + +from Cython.Build import cythonize, build_ext +import numpy +numpy_includes=numpy.get_include() + # setuptools DWIM monkey-patch madness # http://mail.python.org/pipermail/distutils-sig/2007-September/thread.html#8204 #import sys @@ -82,19 +92,24 @@ libqpms_sources = [ ] ''' +common_libs=['qpms', 'gsl', 'lapacke', 'blas', 'pthread',] + cycommon = Extension('qpms.cycommon', sources = ['qpms/cycommon.pyx'], #extra_link_args=['qpms/libqpms.a'], - libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',] + libraries = common_libs, + include_dirs = [numpy_includes], ) cytmatrices = Extension('qpms.cytmatrices', sources = ['qpms/cytmatrices.pyx'], #extra_link_args=['qpms/libqpms.a', 'amos/libamos.a'], - libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',] + libraries = common_libs, + include_dirs = [numpy_includes], ) cywaves = Extension('qpms.cywaves', sources = ['qpms/cywaves.pyx'], - libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',] + libraries = common_libs, + include_dirs = [numpy_includes], ) cytranslations = Extension('qpms.cytranslations', sources = ['qpms/cytranslations.pyx', @@ -104,51 +119,49 @@ cytranslations = Extension('qpms.cytranslations', '-DQPMS_COMPILE_PYTHON_EXTENSIONS', # This is needed to enable it in translations.h ], #extra_link_args=['qpms/libqpms.a', 'amos/libamos.a'], - libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',] + libraries = common_libs, + include_dirs = [numpy_includes], ) cybspec = Extension('qpms.cybspec', sources = ['qpms/cybspec.pyx'], #extra_link_args=['qpms/libqpms.a'], - libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',] + libraries = common_libs, + include_dirs = [numpy_includes], ) cymaterials = Extension('qpms.cymaterials', sources = ['qpms/cymaterials.pyx'], #extra_link_args=['qpms/libqpms.a'], - libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',] + libraries = common_libs, + include_dirs = [numpy_includes], ) cyquaternions = Extension('qpms.cyquaternions', sources = ['qpms/cyquaternions.pyx'], #extra_link_args=['amos/libamos.a', 'qpms/libqpms.a'], - libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',] + libraries = common_libs, + include_dirs = [numpy_includes], ) cyewaldtest = Extension('qpms.cyewaldtest', sources = ['qpms/cyewaldtest.pyx'], - libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',] + libraries = common_libs, + include_dirs = [numpy_includes], ) qpms_c = Extension('qpms.qpms_c', - sources = [ - 'qpms/qpms_c.pyx', - ], - libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread', #'omp' - #('amos', dict(sources=amos_sources) ), - ], - include_dirs=['amos', 'qpms'], + sources = ['qpms/qpms_c.pyx',], + libraries = common_libs, + include_dirs=['amos', 'qpms', numpy_includes], extra_link_args=['-fopenmp'], extra_compile_args=['-fopenmp'], - #extra_link_args=[ 'qpms/libqpms.a','amos/libamos.a', ], - #runtime_library_dirs=os.environ['LD_LIBRARY_PATH'].split(':') if 'LD_LIBRARY_PATH' in os.environ else [], - #extra_objects = ['amos/libamos.a'], # FIXME apparently, I would like to eliminate the need to cmake/make first ) setup(name='qpms', version = "0.2.996", packages=['qpms'], # libraries = [('amos', {'sources': amos_sources} )], - setup_requires=['cython>=0.28',], + setup_requires=['cython>=0.28','numpy>=1.2','setuptools>=18.0'], install_requires=['cython>=0.28', #'quaternion','spherical_functions', - 'scipy>=0.18.0', 'sympy>=1.2'], + 'scipy>=0.18.0', 'sympy>=1.2', 'numpy>=1.2'], #dependency_links=['https://github.com/moble/quaternion/archive/v2.0.tar.gz','https://github.com/moble/spherical_functions/archive/master.zip'], ext_modules=cythonize([qpms_c, cywaves, cytranslations, cytmatrices, cycommon, cyquaternions, cybspec, cymaterials, cyewaldtest], include_path=['qpms', 'amos'], gdb_debug=True), cmdclass = {'build_ext': build_ext},