Beispiel #1
0
def checkOptionalModules(env):
    ######## scipy
    if not detectModule(env, 'scipy'):
        env['warnings'].append("Cannot import scipy. NetCDF sources will not be available for inversions.")

    ######## pyproj
    if not detectModule(env, 'pyproj'):
        env['warnings'].append("Cannot import pyproj. Inversions may not work.")

    ######## gdal
    if not detectModule(env, 'gdal'):
        env['warnings'].append("Cannot import gdal. Inversions will not honour WKT coordinate system information.")

    ######## sympy
    if not detectModule(env, 'sympy'):
        env['warnings'].append("Cannot import sympy. Symbolic toolbox and nonlinear PDEs will not be available.")
    else:
        if env['pythoncmd'] is not None:
            get_external_python_sympy(env['pythoncmd'])
        else:
            import sympy as sp
            spVer=sp.__version__
            spl=spVer.split('.')
            if int(spl[0]) == 0 and int(spl[1]) < 7:
                env['sympy']=False
                env['warnings'].append("sympy version too old. Symbolic toolbox and nonlinear PDEs will not be available.")

    ######## gmshpy
    env['gmshpy'] = detectModule(env, 'gmshpy')

    return env
Beispiel #2
0
def checkOptionalModules(env):
    ######## scipy
    if not detectModule(env, 'scipy'):
        env['warnings'].append("Cannot import scipy. NetCDF sources will not be available for inversions.")

    ######## pyproj
    if not detectModule(env, 'pyproj'):
        env['warnings'].append("Cannot import pyproj. Inversions may not work.")

    ######## gdal
    if not detectModule(env, 'gdal'):
        env['warnings'].append("Cannot import gdal. Inversions will not honour WKT coordinate system information.")

    ######## sympy
    if not detectModule(env, 'sympy'):
        env['warnings'].append("Cannot import sympy. Symbolic toolbox and nonlinear PDEs will not be available.")
    else:
        if env['pythoncmd'] is not None:
            env=get_external_python_sympy(env, env['pythoncmd'])
        else:
            import sympy as sp
            import distutils.version as duv
            spVer=sp.__version__
            spl=spVer.split('.')
            if duv.LooseVersion(sympy.__version__) < duv.LooseVersion('0.7'):
                env['sympy']=False
                env['warnings'].append("sympy version too old. Symbolic toolbox and nonlinear PDEs will not be available.")
            if duv.LooseVersion(sympy.__version__) > duv.LooseVersion('1.2'):
                env['sympy']=False
                env['warnings'].append("escript does not support sympy version 1.2 and higher. Found %d" % duv.LooseVersion(sympy.__version__))

    ######## gmshpy
    env['gmshpy'] = detectModule(env, 'gmshpy')

    return env
Beispiel #3
0
def checkNumpy(env):
    if not detectModule(env, 'numpy'):
        print(
            "Cannot import numpy. If it is installed try setting your PYTHONPATH and probably %s"
            % env['LD_LIBRARY_PATH_KEY'])
        env.Exit(1)

    ## check for numpy header (optional)
    conf = Configure(env.Clone())
    numpy_h = False
    if conf.CheckCXXHeader(['Python.h', 'numpy/ndarrayobject.h']):
        numpy_h = True
    else:
        conda_prefix = os.environ.get('CONDA_PREFIX')
        if conda_prefix:
            # make a copy of CPPPATH so it can be restored if header check fails
            cpp_path_old = conf.env.get('CPPPATH', []).copy()
            conf.env.Append(CPPPATH=[
                conda_prefix + '/Lib/site-packages/numpy/core/include'
            ])
            if conf.CheckCXXHeader(['Python.h', 'numpy/ndarrayobject.h']):
                numpy_h = True
            else:
                conf.env['CPPPATH'] = cpp_path_old

    conf.env['numpy_h'] = numpy_h
    if numpy_h:
        conf.env.Append(CPPDEFINES=['ESYS_HAVE_NUMPY_H'])

    return conf.Finish()
Beispiel #4
0
def checkNumpy(env):
    if not detectModule(env, 'numpy'):
        print("Cannot import numpy. If it is installed try setting your PYTHONPATH and probably %s"%env['LD_LIBRARY_PATH_KEY'])
        env.Exit(1)

    ## check for numpy header (optional)
    conf = Configure(env.Clone())
    if conf.CheckCXXHeader(['Python.h','numpy/ndarrayobject.h']):
        conf.env.Append(CPPDEFINES = ['ESYS_HAVE_NUMPY_H'])
        conf.env['numpy_h']=True
    else:
        conf.env['numpy_h']=False

    return conf.Finish()