Beispiel #1
0
def post_build_ext_hook(cmd):
    """Build the xpans executable and then run ``make distclean`` in the xpa
    directory"""
    # get all the important information
    compiler = cmd.compiler
    libxpa = cmd.ext_map['pyds9.libxpa']
    flags = libxpa.extra_compile_args
    include_dirs = libxpa.include_dirs
    build_lib = cmd.build_lib
    build_temp = cmd.build_temp
    # shorter name for getmtime
    gettime = os.path.getmtime
    force_rebuild = get_distutils_build_option('force')

    # build the file names
    xpans_c = os.path.join('cextern', 'xpa', 'xpans.c')
    xpans_o = os.path.join(build_temp, xpans_c.replace('.c', '.o'))
    xpans = os.path.join(build_lib, cmd.distribution.get_name(), 'xpans')
    xpa_o = glob.glob(xpans_o.replace('xpans', '*'))

    # decide whether to recompile the object file
    if os.path.exists(xpans_o):
        make_obj = gettime(xpans_o) < gettime(xpans_c)
        headers = sum(
            (glob.glob(os.path.join(i, '*.h')) for i in include_dirs), [])
        make_obj |= any(gettime(xpans_o) < gettime(i) for i in headers)
    else:
        make_obj = True
    # use distutils compiler to build the xpans.o
    if make_obj or force_rebuild:
        compiler.compile([
            xpans_c,
        ],
                         output_dir=build_temp,
                         include_dirs=include_dirs,
                         debug=get_distutils_build_option('debug'),
                         extra_postargs=flags,
                         depends=[
                             xpans_c,
                         ])
    # decide whether to recompile the executable
    if os.path.exists(xpans):
        make_exe = gettime(xpans) < gettime(xpans_o)
        make_obj |= any(gettime(xpans) < gettime(i) for i in xpa_o)
    else:
        make_exe = True
    # compile the executable by hand
    if make_exe or force_rebuild:
        compile_cmd = compiler.compiler
        compile_cmd += ['-o', xpans, xpans_o] + xpa_o
        compile_cmd += flags
        print(" ".join(compile_cmd))
        sp.check_call(compile_cmd)

    # run make clean
    xpa_dir = [i for i in libxpa.include_dirs if 'xpa' in i][0]

    with cd(xpa_dir):
        sp.check_call(['make', 'distclean'])
Beispiel #2
0
def post_build_ext_hook(cmd):
    """Build the xpans executable and then run ``make distclean`` in the xpa
    directory"""
    # get all the important information
    compiler = cmd.compiler
    libxpa = [e for e in cmd.extensions if e.name == libxpa_extension_name][0]
    flags = libxpa.extra_compile_args
    include_dirs = libxpa.include_dirs
    build_lib = cmd.build_lib
    build_temp = cmd.build_temp
    # shorter name for getmtime
    gettime = os.path.getmtime
    force_rebuild = get_distutils_build_option('force')

    # build the file names
    xpans_c = os.path.join('cextern', 'xpa', 'xpans.c')
    xpans_o = os.path.join(build_temp, xpans_c.replace('.c', '.o'))
    xpans = os.path.join(build_lib, cmd.distribution.get_name(), 'xpans')
    xpa_o = glob.glob(xpans_o.replace('xpans', '*'))

    # decide whether to recompile the object file
    if os.path.exists(xpans_o):
        make_obj = gettime(xpans_o) < gettime(xpans_c)
        headers = sum((glob.glob(os.path.join(i, '*.h'))
                       for i in include_dirs), [])
        make_obj |= any(gettime(xpans_o) < gettime(i) for i in headers)
    else:
        make_obj = True
    # use distutils compiler to build the xpans.o
    if make_obj or force_rebuild:
        compiler.compile([xpans_c, ], output_dir=build_temp,
                         include_dirs=include_dirs,
                         debug=get_distutils_build_option('debug'),
                         extra_postargs=flags, depends=[xpans_c, ])
    # decide whether to recompile the executable
    if os.path.exists(xpans):
        make_exe = gettime(xpans) < gettime(xpans_o)
        make_obj |= any(gettime(xpans) < gettime(i) for i in xpa_o)
    else:
        make_exe = True
    # compile the executable by hand
    if make_exe or force_rebuild:
        objects = list(set(xpa_o + [xpans_o, ]))
        compile_cmd = compiler.compiler
        compile_cmd += ['-o', xpans] + objects
        compile_cmd += flags
        print(" ".join(compile_cmd))
        sp.check_call(compile_cmd)

    # run make clean
    xpa_dir = [i for i in libxpa.include_dirs if 'xpa' in i][0]

    with cd(xpa_dir):
        sp.check_call(['make', 'distclean'])
Beispiel #3
0
def get_wcslib_cfg(cfg, wcslib_files, include_paths):
    from astropy.version import debug

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

    if (not setup_helpers.use_system_library('wcslib') or
            sys.platform == 'win32'):
        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)
    else:
        wcsconfig_h_path = join(WCSROOT, 'include', 'wcsconfig.h')
        if os.path.exists(wcsconfig_h_path):
            os.unlink(wcsconfig_h_path)
        cfg.update(setup_helpers.pkg_config(['wcslib'], ['wcs']))

    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 setup_helpers.get_compiler_option() in ('unix', 'mingw32'):
        if not get_distutils_build_option('debug'):
            cfg['extra_compile_args'].extend([
                '-Wno-strict-prototypes',
                '-Wno-unused-function',
                '-Wno-unused-value',
                '-Wno-uninitialized',
                #'-Wno-unused-but-set-variable'])
                ])
Beispiel #4
0
def get_wcslib_cfg(cfg, wcslib_files, include_paths):

    debug = import_file(os.path.join(WCSROOT, '..', 'version.py')).debug

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

    if (not setup_helpers.use_system_library('wcslib') or
            sys.platform == 'win32'):
        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)
    else:
        wcsconfig_h_path = join(WCSROOT, 'include', 'wcsconfig.h')
        if os.path.exists(wcsconfig_h_path):
            os.unlink(wcsconfig_h_path)
        cfg.update(setup_helpers.pkg_config(['wcslib'], ['wcs']))

    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 setup_helpers.get_compiler_option() in ('unix', 'mingw32'):
        if not get_distutils_build_option('debug'):
            cfg['extra_compile_args'].extend([
                '-Wno-strict-prototypes',
                '-Wno-unused-function',
                '-Wno-unused-value',
                '-Wno-uninitialized'])
Beispiel #5
0
def post_build_ext_hook(cmd):
    "Build the xpans executable"
    # get all the important information
    compiler = cmd.compiler
    libxpa = cmd.ext_map['pyds9.libxpa']
    flags = libxpa.extra_compile_args
    include_dirs = libxpa.include_dirs
    build_lib = cmd.build_lib
    build_temp = cmd.build_temp
    # shorter name for getmtime
    gettime = os.path.getmtime
    force_rebuild = get_distutils_build_option('force')

    # build the file names
    xpans_c = os.path.join('cextern', 'xpa', 'xpans.c')
    xpans_o = os.path.join(build_temp, xpans_c.replace('.c', '.o'))
    xpans = os.path.join(build_lib, cmd.distribution.get_name(), 'xpans')
    xpa_o = glob.glob(xpans_o.replace('xpans', '*'))

    # decide whether to recompile the object file
    if os.path.exists(xpans_o):
        make_obj = gettime(xpans_o) < gettime(xpans_c)
        headers = sum((glob.glob(os.path.join(i, '*.h'))
                       for i in include_dirs), [])
        make_obj |= any(gettime(xpans_o) < gettime(i) for i in headers)
    else:
        make_obj = True
    # use distutils compiler to build the xpans.o
    if make_obj or force_rebuild:
        compiler.compile([xpans_c, ], output_dir=build_temp,
                         include_dirs=include_dirs,
                         debug=get_distutils_build_option('debug'),
                         extra_postargs=flags, depends=[xpans_c, ])
    # decide whether to recompile the executable
    if os.path.exists(xpans):
        make_exe = gettime(xpans) < gettime(xpans_o)
        make_obj |= any(gettime(xpans) < gettime(i) for i in xpa_o)
    else:
        make_exe = True
    # compile the executable by hand
    if make_exe or force_rebuild:
        compile_cmd = compiler.compiler
        compile_cmd += ['-o', xpans, xpans_o] + xpa_o
        compile_cmd += flags
        print(" ".join(compile_cmd))
        sp.check_call(compile_cmd)
Beispiel #6
0
def _get_debug_option(package_name):
    # Only modify the debug flag if one of the build commands was explicitly
    # run (i.e. not as a sub-command of something else)
    dist = get_dummy_distribution()
    if any(cmd in dist.commands for cmd in ['build', 'build_ext']):
        if bool(get_distutils_build_option('debug')):
            build_ext_cmd = dist.get_command_class('build_ext')
            build_ext_cmd.force_rebuild = True
            return True

    return False
Beispiel #7
0
def _get_debug_option(package_name):
    # Only modify the debug flag if one of the build commands was explicitly
    # run (i.e. not as a sub-command of something else)
    dist = get_dummy_distribution()
    if any(cmd in dist.commands for cmd in ['build', 'build_ext']):
        if bool(get_distutils_build_option('debug')):
            build_ext_cmd = dist.get_command_class('build_ext')
            build_ext_cmd.force_rebuild = True
            return True

    return False
Beispiel #8
0
def _get_compression_extension():
    # 'numpy' will be replaced with the proper path to the numpy includes
    cfg = setup_helpers.DistutilsExtensionArgs()
    cfg['include_dirs'].append('numpy')
    cfg['sources'].append(os.path.join(os.path.dirname(__file__), 'src',
                                       'compressionmodule.c'))

    if not setup_helpers.use_system_library('cfitsio'):
        if setup_helpers.get_compiler_option() == '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'
            ])

            if not get_distutils_build_option('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)
    else:
        cfg.update(setup_helpers.pkg_config(['cfitsio'], ['cfitsio']))

    return Extension('astropy.io.fits.compression', **cfg)
Beispiel #9
0
def _get_compression_extension():
    # 'numpy' will be replaced with the proper path to the numpy includes
    cfg = setup_helpers.DistutilsExtensionArgs()
    cfg['include_dirs'].append('numpy')
    cfg['sources'].append(os.path.join(os.path.dirname(__file__), 'src',
                                       'compressionmodule.c'))

    if not setup_helpers.use_system_library('cfitsio'):
        if setup_helpers.get_compiler_option() == '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'
            ])

            if not get_distutils_build_option('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)
    else:
        cfg.update(setup_helpers.pkg_config(['cfitsio'], ['cfitsio']))

    return Extension('astropy.io.fits.compression', **cfg)
Beispiel #10
0
def get_extensions():
    ulist = platform.uname()
    xpa_dir = os.path.join('cextern', 'xpa')
    debug = get_distutils_build_option('debug')

    # libxpa configurations
    cfg = setup_helpers.DistutilsExtensionArgs()
    cfg['extra_compile_args'].append('-DHAVE_CONFIG_H')

    if 'CFLAGS' not in os.environ and struct.calcsize("P") == 4:
        if ulist[0] == 'Darwin' or ulist[4] == 'x86_64':
            if debug:
                print('adding -m32 to compiler flags ...')
            cflags = '-m32'
            cfg['extra_compile_args'].append(cflags)

    # cfg['extra_compile_args'].extend([# '--enable-shared',
    #                                   '--without-tcl',
    #                                   cflags])

    # import pdb; pdb.set_trace()

    if not setup_helpers.use_system_library('libxpa'):
        if not debug:
            # All of these switches are to silence warnings from compiling
            cfg['extra_compile_args'].extend([
                '-Wno-declaration-after-statement', '-Wno-unused-variable',
                '-Wno-parentheses', '-Wno-uninitialized', '-Wno-format',
                '-Wno-strict-prototypes', '-Wno-unused', '-Wno-comments',
                '-Wno-switch', '-Wno-strict-aliasing', '-Wno-return-type',
                '-Wno-address', '-Wno-unused-result'
            ])

        cfg['include_dirs'].append(xpa_dir)
        sources = [
            'xpa.c', 'xpaio.c', 'command.c', 'acl.c', 'remote.c',
            'clipboard.c', 'port.c', 'tcp.c', 'client.c', 'word.c', 'xalloc.c',
            'find.c', 'xlaunch.c', 'timedconn.c', 'tclloop.c', 'tcl.c'
        ]
        cfg['sources'].extend([os.path.join(xpa_dir, s) for s in sources])
    else:
        cfg.update(setup_helpers.pkg_config(['libxpa'], ['libxpa']))

    libxpa = Extension(libxpa_extension_name, **cfg)

    return [
        libxpa,
    ]
Beispiel #11
0
def get_extensions():
    ulist = platform.uname()
    xpa_dir = os.path.join('cextern', 'xpa')
    debug = get_distutils_build_option('debug')

    # libxpa configurations
    cfg = setup_helpers.DistutilsExtensionArgs()
    cfg['extra_compile_args'].append('-DHAVE_CONFIG_H')

    if 'CFLAGS' not in os.environ and struct.calcsize("P") == 4:
        if ulist[0] == 'Darwin' or ulist[4] == 'x86_64':
            if debug:
                print('adding -m32 to compiler flags ...')
            cflags = '-m32'
            cfg['extra_compile_args'].append(cflags)

    # cfg['extra_compile_args'].extend([# '--enable-shared',
    #                                   '--without-tcl',
    #                                   cflags])

    # import pdb; pdb.set_trace()

    if not setup_helpers.use_system_library('libxpa'):
        if not debug:
            # All of these switches are to silence warnings from compiling
            cfg['extra_compile_args'].extend([
                '-Wno-declaration-after-statement',
                '-Wno-unused-variable', '-Wno-parentheses',
                '-Wno-uninitialized', '-Wno-format',
                '-Wno-strict-prototypes', '-Wno-unused', '-Wno-comments',
                '-Wno-switch', '-Wno-strict-aliasing', '-Wno-return-type',
                '-Wno-address', '-Wno-unused-result'
            ])

        cfg['include_dirs'].append(xpa_dir)
        sources = ['xpa.c', 'xpaio.c', 'command.c', 'acl.c', 'remote.c',
                   'clipboard.c', 'port.c', 'tcp.c', 'client.c', 'word.c',
                   'xalloc.c', 'find.c', 'xlaunch.c', 'timedconn.c',
                   'tclloop.c', 'tcl.c']
        cfg['sources'].extend([os.path.join(xpa_dir, s) for s in sources])
    else:
        cfg.update(setup_helpers.pkg_config(['libxpa'], ['libxpa']))

    libxpa = Extension(libxpa_extension_name, **cfg)

    return [libxpa, ]
Beispiel #12
0
def get_extensions():
    # 'numpy' will be replaced with the proper path to the numpy includes
    cfg = setup_helpers.DistutilsExtensionArgs()
    cfg['include_dirs'].append('numpy')
    cfg['sources'].extend(
        os.path.relpath(fname) for fname in
        glob(os.path.join(os.path.dirname(__file__), 'src', '*.c')))

    if not setup_helpers.use_system_library('cfitsio'):
        if setup_helpers.get_compiler_option() == 'msvc':
            # These come from the CFITSIO vcc makefile
            cfg['extra_compile_args'].extend([
                    '/D', '"WIN32"',
                    '/D', '"_WINDOWS"',
                    '/D', '"_MBCS"',
                    '/D', '"_USRDLL"',
                    '/D', '"_CRT_SECURE_NO_DEPRECATE"'])
        else:
            cfg['extra_compile_args'].extend([
                '-Wno-declaration-after-statement'
            ])

            if not get_distutils_build_option('debug'):
                # All of these switches are to silence warnings from compiling
                # CFITSIO
                cfg['extra_compile_args'].extend([
                    '-Wno-unused-variable', '-Wno-parentheses',
                    '-Wno-uninitialized', '-Wno-format',
                    '-Wno-strict-prototypes', '-Wno-unused', '-Wno-comments',
                    '-Wno-switch', '-Wno-strict-aliasing', '-Wno-return-type',
                    '-Wno-address', '-Wno-unused-result'
                ])

        cfitsio_path = os.path.join('cextern', 'cfitsio')
        cfitsio_files = glob(os.path.join(cfitsio_path, '*.c'))
        cfg['include_dirs'].append(cfitsio_path)
        cfg['sources'].extend(cfitsio_files)
    else:
        cfg.update(setup_helpers.pkg_config(['cfitsio'], ['cfitsio']))

    return [Extension('astropy.io.fits.compression', **cfg)]
def _get_compression_extension():
    # 'numpy' will be replaced with the proper path to the numpy includes
    cfg = setup_helpers.DistutilsExtensionArgs()
    cfg['include_dirs'].append('numpy')
    cfg['sources'].append(os.path.join(os.path.dirname(__file__), 'src',
                                       'compressionmodule.c'))

    if not setup_helpers.use_system_library('cfitsio'):
        if setup_helpers.get_compiler_option() == 'msvc':
            # These come from the CFITSIO vcc makefile
            cfg['extra_compile_args'].extend([
                    '/D', '"WIN32"',
                    '/D', '"_WINDOWS"',
                    '/D', '"_MBCS"',
                    '/D', '"_USRDLL"',
                    '/D', '"_CRT_SECURE_NO_DEPRECATE"'])
        else:
            cfg['extra_compile_args'].extend([
                '-Wno-declaration-after-statement'
            ])

            if not get_distutils_build_option('debug'):
                # All of these switches are to silence warnings from compiling
                # CFITSIO
                cfg['extra_compile_args'].extend([
                    '-Wno-unused-variable', '-Wno-parentheses',
                    '-Wno-uninitialized', '-Wno-format-overflow',
                    '-Wno-strict-prototypes', '-Wno-unused', '-Wno-comments',
                    '-Wno-switch', '-Wno-strict-aliasing', '-Wno-return-type',
                    '-Wno-address', '-Wno-unused-result',
                    '-Wno-misleading-indentation'
                ])

        cfitsio_path = os.path.join('cextern', 'cfitsio')
        cfitsio_files = glob(os.path.join(cfitsio_path, '*.c'))
        cfg['include_dirs'].append(cfitsio_path)
        cfg['sources'].extend(cfitsio_files)
    else:
        cfg.update(setup_helpers.pkg_config(['cfitsio'], ['cfitsio']))

    return Extension('astropy.io.fits.compression', **cfg)
def get_extensions():
    from astropy_helpers import (distutils_helpers, openmp_helpers,
                                 setup_helpers)
    from distutils.core import Extension

    pkg_config_packages = ['gsl']

    sources = [
        'src/bayestar_distance.c',
        'src/bayestar_moc.c',
        'src/bayestar_sky_map.c',
        'src/core.c',
        'src/cubic_interp.c',
        'src/cubic_interp_test.c',
    ]

    include_dirs = ['cextern/numpy', 'numpy']

    if setup_helpers.use_system_library('chealpix'):
        pkg_config_packages.append('chealpix')
    else:
        include_dirs.append('cextern/chealpix')
        sources.append('cextern/chealpix/chealpix.c')

    kwargs = setup_helpers.pkg_config(pkg_config_packages, [])
    kwargs['include_dirs'].extend(include_dirs)
    kwargs['extra_compile_args'].extend(
        ['-std=gnu99', '-DGSL_RANGE_CHECK_OFF'])

    if distutils_helpers.get_distutils_build_option('with_ittnotify'):
        kwargs.setdefault('define_macros', []).append(('WITH_ITTNOTIFY', 1))
        kwargs.setdefault('libraries', []).append('ittnotify')

    extension = Extension(name='ligo.skymap.core',
                          language='c',
                          sources=sources,
                          **kwargs)

    openmp_helpers.add_openmp_flags_if_available(extension)

    return [extension]