Beispiel #1
0
def get_extensions():
    if setup_helpers.get_compiler_option() != 'msvc':
        extra_compile_args = ['-Wno-unused-function',
                              '-Wno-strict-prototypes']
    else:
        extra_compile_args = []
    return [
        Extension(
            'astropy.io.fits.compression',
            [os.path.relpath(x) for x in
             glob(os.path.join(os.path.dirname(__file__), 'src/*.c'))],
            include_dirs=[setup_helpers.get_numpy_include_path()],
            extra_compile_args=extra_compile_args)
    ]
Beispiel #2
0
def get_extensions(build_type='release'):
    write_wcsconfig_h()
    generate_c_docstrings()

    ######################################################################
    # WCSLIB
    wcslib_path = join(WCSROOT, "src", "wcslib")  # Path to wcslib
    wcslib_cpath = join(wcslib_path, "C")  # Path to wcslib source files
    wcslib_files = [  # List of wcslib files to compile
        'flexed/wcsbth.c',
        'flexed/wcspih.c',
        'flexed/wcsulex.c',
        'flexed/wcsutrn.c',
        'cel.c',
        'lin.c',
        'log.c',
        'prj.c',
        'spc.c',
        'sph.c',
        'spx.c',
        'tab.c',
        'wcs.c',
        'wcserr.c',
        'wcsfix.c',
        'wcshdr.c',
        'wcsprintf.c',
        'wcsunits.c',
        'wcsutil.c']
    wcslib_files = [join(wcslib_cpath, x) for x in wcslib_files]

    ######################################################################
    # ASTROPY.WCS-SPECIFIC AND WRAPPER SOURCE FILES
    astropy_wcs_files = [  # List of astropy.wcs files to compile
        'distortion.c',
        'distortion_wrap.c',
        'docstrings.c',
        'pipeline.c',
        'pyutil.c',
        'astropy_wcs.c',
        'astropy_wcs_api.c',
        'sip.c',
        'sip_wrap.c',
        'str_list_proxy.c',
        'wcslib_wrap.c',
        'wcslib_tabprm_wrap.c',
        'wcslib_units_wrap.c',
        'wcslib_wtbarr_wrap.c']
    astropy_wcs_files = [join(WCSROOT, 'src', x) for x in astropy_wcs_files]

    ######################################################################
    # DISTUTILS SETUP
    libraries = []
    define_macros = [
        ('ECHO', None),
        ('WCSTRIG_MACRO', None),
        ('ASTROPY_WCS_BUILD', None),
        ('_GNU_SOURCE', None),
        ('WCSVERSION', WCSVERSION)]
    undef_macros = []
    extra_compile_args = []
    extra_link_args = []

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

    if sys.platform == 'win32':
        define_macros.append(('YY_NO_UNISTD_H', None))
        define_macros.append(('_CRT_SECURE_NO_WARNINGS', None))
        define_macros.append(('_NO_OLDNAMES', None))  # for mingw32
        define_macros.append(('NO_OLDNAMES', None))  # for mingw64

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

    return [
        Extension('astropy.wcs._wcs',
                  wcslib_files + astropy_wcs_files,
                  include_dirs=[
                      setup_helpers.get_numpy_include_path(),
                      wcslib_cpath,
                      join(WCSROOT, "src")],
                  define_macros=define_macros,
                  undef_macros=undef_macros,
                  extra_compile_args=extra_compile_args,
                  extra_link_args=extra_link_args,
                  libraries=libraries)]
Beispiel #3
0
# Licensed under a 3-clause BSD style license - see LICENSE.rst

from __future__ import absolute_import, division, print_function, unicode_literals

import os

if __name__ == "__main__":
    from astropy import wcs
    from astropy import setup_helpers
    from distutils.core import setup, Extension

    wcsapi_test_module = Extension(
        str("wcsapi_test"),
        include_dirs=[
            setup_helpers.get_numpy_include_path(),
            os.path.join(wcs.get_include(), "astropy_wcs"),
            os.path.join(wcs.get_include(), "wcslib"),
        ],
        # Use the *full* name to the c file, since we can't change the cwd
        # during testing
        sources=[str(os.path.join(os.path.dirname(__file__), "wcsapi_test.c"))],
    )

    setup(name="wcsapi_test", ext_modules=[wcsapi_test_module])
Beispiel #4
0
# Licensed under a 3-clause BSD style license - see LICENSE.rst

from __future__ import absolute_import, division, print_function, unicode_literals

import os
import sys

if __name__ == '__main__':
    astropy_path = sys.argv[-1]
    sys.argv = sys.argv[:-1]
    sys.path.insert(0, astropy_path)

    from astropy import wcs
    from astropy import setup_helpers
    from distutils.core import setup, Extension

    wcsapi_test_module = Extension(
        str('wcsapi_test'),
        include_dirs=[
            setup_helpers.get_numpy_include_path(),
            os.path.join(wcs.get_include(), 'astropy_wcs'),
            os.path.join(wcs.get_include(), 'wcslib')
        ],
        # Use the *full* name to the c file, since we can't change the cwd
        # during testing
        sources=[
            str(os.path.join(os.path.dirname(__file__), 'wcsapi_test.c'))
        ])

    setup(name='wcsapi_test', ext_modules=[wcsapi_test_module])
Beispiel #5
0
def get_extensions():
    from astropy.version import debug

    generate_c_docstrings()

    ######################################################################
    # DISTUTILS SETUP
    source_files = []
    libraries = []
    include_dirs = [
        setup_helpers.get_numpy_include_path(),
        join(WCSROOT, "include")]

    library_dirs = []
    define_macros = [
        ('ECHO', None),
        ('WCSTRIG_MACRO', None),
        ('ASTROPY_WCS_BUILD', None),
        ('_GNU_SOURCE', None),
        ('WCSVERSION', WCSVERSION)]
    undef_macros = []
    extra_compile_args = []
    extra_link_args = []

    if (not setup_helpers.use_system_library('wcslib') or
        sys.platform == 'win32'):
        write_wcsconfig_h()

        wcslib_path = join("cextern", "wcslib")  # Path to wcslib
        wcslib_cpath = join(wcslib_path, "C")  # Path to wcslib source files
        wcslib_files = [  # List of wcslib files to compile
            'flexed/wcsbth.c',
            'flexed/wcspih.c',
            'flexed/wcsulex.c',
            'flexed/wcsutrn.c',
            'cel.c',
            'lin.c',
            'log.c',
            'prj.c',
            'spc.c',
            'sph.c',
            'spx.c',
            'tab.c',
            'wcs.c',
            'wcserr.c',
            'wcsfix.c',
            'wcshdr.c',
            'wcsprintf.c',
            'wcsunits.c',
            'wcsutil.c']
        source_files.extend(join(wcslib_cpath, x) for x in wcslib_files)
        include_dirs.append(wcslib_cpath)
    else:
        setup_helpers.pkg_config(
            ['wcs'], ['wcs'], include_dirs, library_dirs, libraries)

    astropy_wcs_files = [  # List of astropy.wcs files to compile
        'distortion.c',
        'distortion_wrap.c',
        'docstrings.c',
        'pipeline.c',
        'pyutil.c',
        'astropy_wcs.c',
        'astropy_wcs_api.c',
        'sip.c',
        'sip_wrap.c',
        'str_list_proxy.c',
        'util.c',
        'wcslib_wrap.c',
        'wcslib_tabprm_wrap.c',
        'wcslib_units_wrap.c',
        'wcslib_wtbarr_wrap.c']
    source_files.extend(join(WCSROOT, 'src', x) for x in astropy_wcs_files)

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

    return [
        Extension('astropy.wcs._wcs',
                  source_files,
                  include_dirs=include_dirs,
                  define_macros=define_macros,
                  undef_macros=undef_macros,
                  extra_compile_args=extra_compile_args,
                  extra_link_args=extra_link_args,
                  libraries=libraries,
                  library_dirs=library_dirs)]