Ejemplo n.º 1
0
def get_compiler_and_build_flag():
    try:
        sys.argv.remove('-openmp')
        openmp_flag = '-openmp'
        assert get_openmp_flag(), 'your system must support openmp'
    except ValueError:
        openmp_flag = ''
    
    try:
        install_type = sys.argv[1]
    except IndexError:
        install_type = ''
    
    try:
        import numpy as np
        has_numpy = True
    except ImportError:
        has_numpy = False

    default_compiler = DEFAULT_MAC_COMPILER if sys.platform == 'darwin' else DEFAULT_LINUX_COMPILER
    compiler = os.environ.get('COMPILER', default_compiler)
    print('using compiler = {}'.format(compiler))

    amberhome = os.environ.get('AMBERHOME', '')
    amberlib = '-amberlib' if amberhome else ''
    
    if amberlib:
        build_flag_ = amberlib
    else:
        if has_numpy and find_lib('openblas'):
            prefix = sys.prefix
            # likely having openblas?
            build_flag_ = '--with-netcdf={prefix} --with-blas={prefix} \
                           --with-bzlib={prefix} --with-zlib={prefix} \
                           -openblas -noarpack'.format(prefix=prefix)
        elif has_numpy:
            try:
                blas_prefix = np.__config__.blas_opt_info['library_dirs'][0].strip('lib')
                lapack_prefix = np.__config__.lapack_opt_info['library_dirs'][0].strip('lib')
                build_flag_ = '-noarpack --with-blas={blas_prefix} --with-lapack={lapack_prefix}'.format(blas_prefix=blas_prefix, lapack_prefix=lapack_prefix)
            except (KeyError, IndexError):
                build_flag_ = '-noarpack'
        else:
            # user gets lucky?
            build_flag_ = '-noarpack'
    
    if sys.platform == 'darwin':
        build_flag = DEFAULT_MAC_BUILD
    else:
        build_flag = ' '.join(('-shared', build_flag_, amberlib, openmp_flag))
    
    if install_type == 'github':
        print('install libcpptraj from github')
        os.system('git clone https://github.com/Amber-MD/cpptraj')
    else:
        print('install libcpptraj from current ./cpptraj folder')
    return compiler, build_flag
Ejemplo n.º 2
0
def get_compiler_and_build_flag():
    try:
        sys.argv.remove('-openmp')
        openmp_flag = '-openmp'
        assert get_openmp_flag(), 'your system must support openmp'
    except ValueError:
        openmp_flag = ''

    try:
        install_type = sys.argv[1]
    except IndexError:
        install_type = ''

    try:
        import numpy as np
        has_numpy = True
    except ImportError:
        has_numpy = False

    compiler = os.environ.get('COMPILER', 'gnu')
    if sys.platform == 'darwin':
        compiler = DEFAULT_MAC_COMPILER
    amberhome = os.environ.get('AMBERHOME', '')
    amberlib = '-amberlib' if amberhome else ''

    if has_numpy and find_lib('openblas'):
        prefix = sys.prefix
        # likely having openblas?
        build_flag_ = '--with-netcdf={prefix} --with-blas={prefix} \
                       --with-bzlib={prefix} --with-zlib={prefix} \
                       -openblas -noarpack'.format(prefix=prefix)
    elif has_numpy:
        try:
            blas_prefix = np.__config__.blas_opt_info['library_dirs'][0].strip(
                'lib')
            lapack_prefix = np.__config__.lapack_opt_info['library_dirs'][
                0].strip('lib')
            build_flag_ = '-noarpack --with-blas={blas_prefix} --with-lapack={lapack_prefix}'.format(
                blas_prefix=blas_prefix, lapack_prefix=lapack_prefix)
        except (KeyError, IndexError):
            build_flag_ = '-noarpack'
    else:
        # user gets lucky?
        build_flag_ = '-noarpack'

    if sys.platform == 'darwin':
        build_flag = DEFAULT_MAC_BUILD
    else:
        build_flag = ' '.join(('-shared', build_flag_, amberlib, openmp_flag))

    if install_type == 'github':
        print('install libcpptraj from github')
        os.system('git clone https://github.com/Amber-MD/cpptraj')
    else:
        print('install libcpptraj from current ./cpptraj folder')
    return compiler, build_flag
Ejemplo n.º 3
0
def get_compiler_and_build_flag():
    args = parse_args()

    openmp_flag = '-openmp' if args.openmp else ''
    if openmp_flag:
        # we turn off OSX openmp anyway, so do not need to check
        if not IS_OSX:
            assert get_openmp_flag(), 'your system must support openmp'

    install_type = args.install_type
    debug = '-debug' if args.debug else ''

    try:
        import numpy as np
        has_numpy = True
    except ImportError:
        has_numpy = False

    # better name for COMPILER?
    # cpptraj: ./configure gnu
    # e.g: COMPILER=gnu python ./scripts/install_libcpptraj.py
    os_dependent_default_compiler = 'clang' if IS_OSX else 'gnu'
    compiler_env = os.environ.get('COMPILER',
                                  '')  # intel | pgi | clang | cray?
    if compiler_env:
        print('libcpptraj: Using COMPILER env = ', compiler_env)
        compiler = compiler_env
    else:
        compiler = os_dependent_default_compiler
        cxx = os.getenv('CXX')
        if cxx:
            print('Using preset CXX', cxx)
            compiler = ''
    if compiler == 'gnu':
        ensure_gnu()
    amberhome = os.environ.get('AMBERHOME', '')
    amberlib = '-amberlib' if amberhome and args.amberlib else ''

    prefix = sys.prefix
    if has_numpy and find_lib('openblas'):
        # likely having openblas?
        build_flag_ = ('--with-netcdf={prefix} --with-blas={prefix} '
                       '-openblas -noarpack'.format(prefix=prefix))
    elif has_numpy:
        print('has_numpy but can not find openblas')
        print('try blas and lapack')
        try:
            blas_prefix = np.__config__.blas_opt_info['library_dirs'][0].strip(
                'lib')
            lapack_prefix = np.__config__.lapack_opt_info['library_dirs'][
                0].strip('lib')
            build_flag_ = (
                '-noarpack --with-blas={blas_prefix} --with-lapack={lapack_prefix}'
                .format(blas_prefix=blas_prefix, lapack_prefix=lapack_prefix))
        except (KeyError, IndexError):
            build_flag_ = '-noarpack'
    else:
        # user gets lucky?
        build_flag_ = '-noarpack'

    zip_stuff = ' --with-bzlib={prefix} --with-zlib={prefix} '.format(
        prefix=prefix)
    build_flag_ += zip_stuff

    if IS_OSX:
        build_flag = ' '.join((DEFAULT_MAC_BUILD, amberlib))
    else:
        build_flag = '--requires-flink ' + ' '.join(
            ('-shared', build_flag_, amberlib, openmp_flag))
        # FIXME: remove --requires-flink if https://github.com/Amber-MD/cpptraj/issues/585 is resolved

    build_flag = ' '.join((build_flag, debug, '-nosanderlib'))

    if install_type == 'github':
        print('install libcpptraj from github')
        subprocess.check_call(
            'git clone https://github.com/Amber-MD/cpptraj'.split())
    else:
        print('install libcpptraj from current ./cpptraj folder')
    return compiler, build_flag