' - please install nibabel first') pybuilder = derror_maker(build_py.build_py, msg) extbuilder = derror_maker(build_ext.build_ext, msg) def package_check(*args, **kwargs): raise RuntimeError(msg + " or try 'python setup_egg.py install'") else: # We have nibabel pybuilder = get_comrec_build('dipy') # Cython is a dependency for building extensions, iff we don't have stamped # up pyx and c files. build_ext = cyproc_exts(EXTS, CYTHON_MIN_VERSION, 'pyx-stamps') # Add openmp flags if they work simple_test_c = """int main(int argc, char** argv) { return(0); }""" omp_test_c = """#include <omp.h> int main(int argc, char** argv) { return(0); }""" extbuilder = add_flag_checking( build_ext, [[['/arch:SSE2'], [], simple_test_c, 'USING_VC_SSE2'], [['-msse2', '-mfpmath=sse'], [], simple_test_c, 'USING_GCC_SSE2'], [['-fopenmp'], ['-fopenmp'], omp_test_c, 'HAVE_OPENMP']], 'dipy') # Installer that checks for install-time dependencies class installer(install.install): def run(self): package_check('numpy', NUMPY_MIN_VERSION) package_check('scipy', SCIPY_MIN_VERSION) package_check('nibabel', NIBABEL_MIN_VERSION) install.install.run(self) cmdclass = dict( build_py=pybuilder, build_ext=extbuilder, install=installer,
"HAVE_OPENMP"]] else: GULINALG_INTEL_OPENMP = 'GULINALG_INTEL_OPENMP' in os.environ if GULINALG_INTEL_OPENMP: # Link to Intel OpenMP library (instead of libgomp default for GCC) # Reference at Intel's site: https://tinyurl.com/yxmf7bwy openmp_link_args = [] openmp_libs = ['iomp5', 'pthread'] else: openmp_link_args = ['-fopenmp'] # OpenMP flags for gcc flag_defines = [[["-fopenmp"], openmp_link_args, omp_test_c, "HAVE_OPENMP"]] extbuilder = add_flag_checking(build_ext, flag_defines, "gulinalg", openmp_libs) cmdclass['build_ext'] = extbuilder else: cmdclass['build_ext'] = build_ext if 'extra_compile_args' not in extra_opts: extra_opts['extra_compile_args'] = [] if "msc" not in platform.python_compiler().lower(): # Need C99 for _Pragma support # On windows, the MSVC-specific __pragma is used instead extra_opts['extra_compile_args'] += ['-std=c99'] gufunc_module = Extension('gulinalg._impl', sources=MODULE_SOURCES, depends=MODULE_DEPENDENCIES,
gcc_flag_defines = [ [['-msse2', '-mfpmath=sse'], [], simple_test_c, 'USING_GCC_SSE2'], [['-fopenmp'], ['-fopenmp'], omp_test_c, 'HAVE_OPENMP'], ] # Test if it is a 32 bits version if not sys.maxsize > 2**32: # This flag is needed only on 32 bits msc_flag_defines += [ [['/arch:SSE2'], [], simple_test_c, 'USING_VC_SSE2'], ] flag_defines = msc_flag_defines if 'msc' in platform.python_compiler().lower( ) else gcc_flag_defines extbuilder = add_flag_checking(build_ext, flag_defines, 'dipy') # Use ext builder to add np.get_include() at build time, not during setup.py # execution. extbuilder = make_np_ext_builder(extbuilder) if need_cython: SetupDependency('Cython', info.CYTHON_MIN_VERSION, req_type='install_requires', heavy=True).check_fill(extra_setuptools_args) SetupDependency('numpy', info.NUMPY_MIN_VERSION, req_type='install_requires', heavy=True).check_fill(extra_setuptools_args) SetupDependency('scipy', info.SCIPY_MIN_VERSION,
int main(int argc, char** argv) { return(0); }""" msc_flag_defines = [[['/openmp'], [], omp_test_c, 'HAVE_VC_OPENMP'], ] gcc_flag_defines = [[['-msse2', '-mfpmath=sse'], [], simple_test_c, 'USING_GCC_SSE2'], [['-fopenmp'], ['-fopenmp'], omp_test_c, 'HAVE_OPENMP'], ] # Test if it is a 32 bits version if not sys.maxsize > 2 ** 32: # This flag is needed only on 32 bits msc_flag_defines += [[['/arch:SSE2'], [], simple_test_c, 'USING_VC_SSE2'], ] flag_defines = msc_flag_defines if 'msc' in platform.python_compiler().lower() else gcc_flag_defines extbuilder = add_flag_checking(build_ext, flag_defines, 'dipy') # Use ext builder to add np.get_include() at build time, not during setup.py # execution. extbuilder = make_np_ext_builder(extbuilder) if need_cython: SetupDependency('Cython', info.CYTHON_MIN_VERSION, req_type='install_requires', heavy=True).check_fill(extra_setuptools_args) SetupDependency('numpy', info.NUMPY_MIN_VERSION, req_type='install_requires', heavy=True).check_fill(extra_setuptools_args) SetupDependency('scipy', info.SCIPY_MIN_VERSION, req_type='install_requires', heavy=True).check_fill(extra_setuptools_args) SetupDependency('nibabel', info.NIBABEL_MIN_VERSION,
try: from nisext.sexts import package_check, get_comrec_build except ImportError: # No nibabel msg = ('Need nisext package from nibabel installation' ' - please install nibabel first') pybuilder = derror_maker(build_py.build_py, msg) extbuilder = derror_maker(build_ext.build_ext, msg) def package_check(*args, **kwargs): raise RuntimeError(msg + " or try 'python setup_egg.py install'") else: # We have nibabel pybuilder = get_comrec_build('dipy') # Cython is a dependency for building extensions, iff we don't have stamped # up pyx and c files. build_ext = cyproc_exts(EXTS, CYTHON_MIN_VERSION, 'pyx-stamps') # Add openmp flags if they work extbuilder = add_flag_checking(build_ext, ['-fopenmp']) # Installer that checks for install-time dependencies class installer(install.install): def run(self): package_check('numpy', NUMPY_MIN_VERSION) package_check('scipy', SCIPY_MIN_VERSION) package_check('nibabel', NIBABEL_MIN_VERSION) install.install.run(self) cmdclass = dict( build_py=pybuilder, build_ext=extbuilder, install=installer, install_scripts=install_scripts_bat,
except ImportError: # No nibabel msg = ('Need nisext package from nibabel installation' ' - please install nibabel first') pybuilder = derror_maker(build_py.build_py, msg) extbuilder = derror_maker(build_ext.build_ext, msg) def package_check(*args, **kwargs): raise RuntimeError(msg + " or try 'python setup_egg.py install'") else: # We have nibabel pybuilder = get_comrec_build('dipy') # Cython is a dependency for building extensions, iff we don't have stamped # up pyx and c files. build_ext = cyproc_exts(EXTS, CYTHON_MIN_VERSION, 'pyx-stamps') # Add openmp flags if they work omp_test_c = """#include <omp.h> int main(int argc, char** argv) { return(0); }""" extbuilder = add_flag_checking( build_ext, [[['-fopenmp'], ['-fopenmp'], omp_test_c, 'HAVE_OPENMP']]) # Fix npymath libraries for Windows if os.name == 'nt': extbuilder = check_npymath(extbuilder) # Installer that checks for install-time dependencies class installer(install.install): def run(self): package_check('numpy', NUMPY_MIN_VERSION) package_check('scipy', SCIPY_MIN_VERSION) package_check('nibabel', NIBABEL_MIN_VERSION) install.install.run(self) cmdclass = dict( build_py=pybuilder,
msg = ('Need nisext package from nibabel installation' ' - please install nibabel first') pybuilder = derror_maker(build_py.build_py, msg) extbuilder = derror_maker(build_ext.build_ext, msg) def package_check(*args, **kwargs): raise RuntimeError(msg + " or try 'python setup_egg.py install'") else: # We have nibabel pybuilder = get_comrec_build('dipy') # Cython is a dependency for building extensions, iff we don't have stamped # up pyx and c files. build_ext = cyproc_exts(EXTS, CYTHON_MIN_VERSION, 'pyx-stamps') # Add openmp flags if they work omp_test_c = """#include <omp.h> int main(int argc, char** argv) { return(0); }""" extbuilder = add_flag_checking( build_ext, [[['-fopenmp'], ['-fopenmp'], omp_test_c, 'HAVE_OPENMP']]) # Fix npymath libraries for Windows if os.name == 'nt': extbuilder = check_npymath(extbuilder) # Installer that checks for install-time dependencies class installer(install.install): def run(self): package_check('numpy', NUMPY_MIN_VERSION) package_check('scipy', SCIPY_MIN_VERSION) package_check('nibabel', NIBABEL_MIN_VERSION) install.install.run(self) cmdclass = dict(build_py=pybuilder,
# [["-msse2", "-mfpmath=sse"], [], simple_test_c, "USING_GCC_SSE2"] # ] if "NUFFT_DISABLE_OPENMP" not in os.environ: msc_flag_defines += [[["/openmp"], [], omp_test_c, "HAVE_VC_OPENMP"]] gcc_flag_defines += [[["-fopenmp"], ["-fopenmp"], omp_test_c, "HAVE_OPENMP"]] # # Test if it is a 32 bits version # if not sys.maxsize > 2 ** 32: # # This flag is needed only on 32 bits # msc_flag_defines += [[["/arch:SSE2"], [], simple_test_c, "USING_VC_SSE2"]] flag_defines = (msc_flag_defines if "msc" in platform.python_compiler().lower() else gcc_flag_defines) extbuilder = add_flag_checking(build_ext, flag_defines, pjoin("mrrt", "nufft")) # add np.get_include() at build time, not during setup.py execution. extbuilder = make_np_ext_builder(extbuilder) # cython check try: import cython # check that cython version is > 0.21 cython_version = cython.__version__ if float(cython_version.partition(".")[2][:2]) < 21: raise ImportError build_cython = True except ImportError: build_cython = False