예제 #1
0
def get_wcslib_cfg(cfg, wcslib_files, include_paths):

    debug = '--debug' in sys.argv

    cfg['include_dirs'].append(numpy.get_include())
    cfg['define_macros'].extend([
        ('ECHO', None),
        ('WCSTRIG_MACRO', None),
        ('ASTROPY_WCS_BUILD', None),
        ('_GNU_SOURCE', None)])

    if ((int(os.environ.get('ASTROPY_USE_SYSTEM_WCSLIB', 0))
            or int(os.environ.get('ASTROPY_USE_SYSTEM_ALL', 0)))
            and not sys.platform == 'win32'):
        wcsconfig_h_path = join(WCSROOT, 'include', 'wcsconfig.h')
        if os.path.exists(wcsconfig_h_path):
            os.unlink(wcsconfig_h_path)
        cfg.update(pkg_config(['wcslib'], ['wcs']))
    else:
        write_wcsconfig_h(include_paths)

        wcslib_path = join("cextern", "wcslib")  # Path to wcslib
        wcslib_cpath = join(wcslib_path, "C")  # Path to wcslib source files
        cfg['sources'].extend(join(wcslib_cpath, x) for x in wcslib_files)
        cfg['include_dirs'].append(wcslib_cpath)

    if debug:
        cfg['define_macros'].append(('DEBUG', None))
        cfg['undef_macros'].append('NDEBUG')
        if (not sys.platform.startswith('sun') and
                not sys.platform == 'win32'):
            cfg['extra_compile_args'].extend(["-fno-inline", "-O0", "-g"])
    else:
        # Define ECHO as nothing to prevent spurious newlines from
        # printing within the libwcs parser
        cfg['define_macros'].append(('NDEBUG', None))
        cfg['undef_macros'].append('DEBUG')

    if sys.platform == 'win32':
        # These are written into wcsconfig.h, but that file is not
        # used by all parts of wcslib.
        cfg['define_macros'].extend([
            ('YY_NO_UNISTD_H', None),
            ('_CRT_SECURE_NO_WARNINGS', None),
            ('_NO_OLDNAMES', None),  # for mingw32
            ('NO_OLDNAMES', None),  # for mingw64
            ('__STDC__', None)  # for MSVC
        ])

    if sys.platform.startswith('linux'):
        cfg['define_macros'].append(('HAVE_SINCOS', None))

    # Squelch a few compilation warnings in WCSLIB
    if get_compiler() in ('unix', 'mingw32'):
        if not debug:
            cfg['extra_compile_args'].extend([
                '-Wno-strict-prototypes',
                '-Wno-unused-function',
                '-Wno-unused-value',
                '-Wno-uninitialized'])
예제 #2
0
def _get_compression_extension():

    debug = '--debug' in sys.argv

    cfg = defaultdict(list)
    cfg['include_dirs'].append(numpy.get_include())
    cfg['sources'].append(
        os.path.join(os.path.dirname(__file__), 'src', 'compressionmodule.c'))

    if (int(os.environ.get('ASTROPY_USE_SYSTEM_CFITSIO', 0))
            or int(os.environ.get('ASTROPY_USE_SYSTEM_ALL', 0))):
        for k, v in pkg_config(['cfitsio'], ['cfitsio']).items():
            cfg[k].extend(v)
    else:
        if get_compiler() == 'msvc':
            # These come from the CFITSIO vcc makefile, except the last
            # which ensures on windows we do not include unistd.h (in regular
            # compilation of cfitsio, an empty file would be generated)
            cfg['extra_compile_args'].extend([
                '/D', 'WIN32', '/D', '_WINDOWS', '/D', '_MBCS', '/D',
                '_USRDLL', '/D', '_CRT_SECURE_NO_DEPRECATE', '/D',
                'FF_NO_UNISTD_H'
            ])
        else:
            cfg['extra_compile_args'].extend(
                ['-Wno-declaration-after-statement'])

            cfg['define_macros'].append(('HAVE_UNISTD_H', None))

            if not debug:
                # these switches are to silence warnings from compiling CFITSIO
                # For full silencing, some are added that only are used in
                # later versions of gcc (versions approximate; see #6474)
                cfg['extra_compile_args'].extend([
                    '-Wno-strict-prototypes',
                    '-Wno-unused',
                    '-Wno-uninitialized',
                    '-Wno-unused-result',  # gcc >~4.8
                    '-Wno-misleading-indentation',  # gcc >~7.2
                    '-Wno-format-overflow',  # gcc >~7.2
                ])

        cfitsio_lib_path = os.path.join('cextern', 'cfitsio', 'lib')
        cfitsio_zlib_path = os.path.join('cextern', 'cfitsio', 'zlib')
        cfitsio_files = glob(os.path.join(cfitsio_lib_path, '*.c'))
        cfitsio_zlib_files = glob(os.path.join(cfitsio_zlib_path, '*.c'))
        cfg['include_dirs'].append(cfitsio_lib_path)
        cfg['include_dirs'].append(cfitsio_zlib_path)
        cfg['sources'].extend(cfitsio_files)
        cfg['sources'].extend(cfitsio_zlib_files)

    return Extension('astropy.io.fits.compression', **cfg)
예제 #3
0
def get_extensions():

    cfg = defaultdict(list)

    szpack_files = [  # List of wcslib files to compile
        'Development/Simple_routines/Relativistic_MB.cpp',
        'Development/Simple_routines/nPl_derivatives.cpp',
        'Development/Simple_routines/routines.cpp',
        'Development/Integration/Patterson.cpp',
        'Development/Integration/Integration_routines.GSL.cpp',
        'Development/Integration/Chebyshev_Int.cpp', 'src/SZ_Integral.5D.cpp',
        'src/SZ_Integral.3D.cpp', 'src/SZ_asymptotic.cpp',
        'src/SZ_CNSN_basis.cpp', 'src/SZ_CNSN_basis.opt.cpp', 'SZpack.cpp',
        'python/SZpack.i', 'python/SZpack.python.cpp'
    ]
    szpack_incdirs = [
        '', 'include', 'Development/Definitions', 'Development/Integration',
        'Development/Simple_routines', 'python'
    ]
    cfg['sources'].extend(
        szpack_dir.joinpath(x).as_posix() for x in szpack_files)
    cfg['include_dirs'].extend(
        szpack_dir.joinpath(x).as_posix() for x in szpack_incdirs)

    # external dependencies
    cfg['include_dirs'].append(numpy.get_include())
    cfg['libraries'].append('m')

    gsl_info = get_gsl_info()

    cfg['include_dirs'].append(gsl_info['incdir'])
    cfg['library_dirs'].append(gsl_info['libdir'])
    cfg['runtime_library_dirs'].append(gsl_info['libdir'])
    cfg['libraries'].extend(gsl_info['libs'])
    cfg['swig_opts'].extend(['-modern', '-c++'])

    if get_compiler() in ('unix', 'mingw32'):
        cfg['extra_compile_args'].extend([
            '-pedantic',
            '-Wno-newline-eof',
            '-Wno-unused-const-variable',
        ])

    extension = Extension('szpack_wrapper.extern._SZpack', **cfg)
    add_openmp_flags_if_available(extension)
    return [
        extension,
    ]
예제 #4
0
def get_extensions():

    if get_compiler() == 'msvc':
        return list()
    else:
        cfg = defaultdict(list)
        cfg['include_dirs'].append(numpy.get_include())
        cfg['sources'].extend(
            sorted(
                glob(
                    os.path.join(os.path.dirname(__file__), 'src', 'ana',
                                 '*.c'))))
        cfg['extra_compile_args'].extend(['-std=c99', '-O3'])
        # Squash some warnings
        cfg['extra_compile_args'].extend([
            '-Wno-unused-but-set-variable', '-Wno-unused-variable',
            '-Wno-unused-result', '-Wno-sign-compare'
        ])

        e = Extension('sunpy.io._pyana', **cfg)
        return [e]