예제 #1
0
def get_extensions():
    ROOT = os.path.relpath(os.path.dirname(__file__))

    cfg = setup_helpers.DistutilsExtensionArgs()
    cfg['include_dirs'].append('numpy')

    sources = [str(os.path.join(ROOT, 'src', 'math_util.c'))]

    if (not setup_helpers.use_system_library('qd') or
        sys.platform == 'win32'):
        qd_library_path = os.path.join(ROOT, '..', 'cextern', 'qd-library')
        qd_library_c_path = os.path.join(qd_library_path, 'src')
        qd_library_include_path = os.path.join(qd_library_path, 'include')

        qd_sources = [
            'bits.cpp',
            'c_dd.cpp',
            'dd_real.cpp',
            'dd_const.cpp',
            'fpu.cpp',
            'util.cpp']

        sources.extend([
            str(os.path.join(qd_library_c_path, x))
            for x in qd_sources])
        cfg['include_dirs'].extend([
            qd_library_include_path,
            str(os.path.join(ROOT, 'src'))])
        cfg['libraries'].append('m')
    else:
        cfg.update(setup_helpers.pkg_config([], ['qd', 'm'], 'qd-config'))

    return [Extension(
        str('spherical_geometry.math_util'), sources, **cfg)]
예제 #2
0
def get_extensions(build_type='release'):
    XML_DIR = 'astropy/utils/xml/src'

    cfg = setup_helpers.DistutilsExtensionArgs({
        'sources': [join(XML_DIR, "iterparse.c")]
        })

    if setup_helpers.use_system_library('expat'):
        cfg.update(setup_helpers.pkg_config(['expat'], ['expat']))
    else:
        EXPAT_DIR = 'cextern/expat/lib'
        cfg['sources'].extend([
            join(EXPAT_DIR, fn) for fn in
            ["xmlparse.c", "xmlrole.c", "xmltok.c", "xmltok_impl.c"]])
        cfg['include_dirs'].extend([XML_DIR, EXPAT_DIR])
        if sys.platform.startswith('linux'):
            # This is to ensure we only export the Python entry point
            # symbols and the linker won't try to use the system expat in
            # place of ours.
            cfg['extra_link_args'].extend([
                '-Wl,--version-script={0}'.format(
                    join(XML_DIR, 'iterparse.map'))
                ])
        cfg['define_macros'].append(("HAVE_EXPAT_CONFIG_H", 1))
        if sys.byteorder == 'big':
            cfg['define_macros'].append(('BYTEORDER', '4321'))
        else:
            cfg['define_macros'].append(('BYTEORDER', '1234'))
        if sys.platform != 'win32':
            cfg['define_macros'].append(('HAVE_UNISTD_H', None))

    return [Extension("astropy.utils.xml._iterparser", **cfg)]
예제 #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'])
                ])
예제 #4
0
def get_extensions():
    sources = [
        os.path.join(ERFAPKGDIR, fn)
        for fn in ("ufunc.c", "pav2pv.c", "pv2pav.c")
    ]
    include_dirs = ['numpy']
    libraries = []

    if setup_helpers.use_system_library('erfa'):
        libraries.append('erfa')
    else:
        # get all of the .c files in the cextern/erfa directory
        erfafns = os.listdir(ERFA_SRC)
        sources.extend(
            ['cextern/erfa/' + fn for fn in erfafns if fn.endswith('.c')])

        include_dirs.append('cextern/erfa')

    erfa_ext = Extension(
        name="astropy._erfa.ufunc",
        sources=sources,
        include_dirs=include_dirs,
        libraries=libraries,
        language="c",
    )

    return [erfa_ext]
예제 #5
0
def get_extensions():
    generate_c_docstrings()

    ######################################################################
    # DISTUTILS SETUP
    cfg = setup_helpers.DistutilsExtensionArgs()

    wcslib_files = [  # List of wcslib files to compile
        'flexed/wcsbth.c', 'flexed/wcspih.c', 'flexed/wcsulex.c',
        'flexed/wcsutrn.c', 'cel.c', 'dis.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_config_paths = [
        join(WCSROOT, 'include', 'astropy_wcs', 'wcsconfig.h'),
        join(WCSROOT, 'include', 'wcsconfig.h')
    ]

    get_wcslib_cfg(cfg, wcslib_files, wcslib_config_paths)

    cfg['include_dirs'].append(join(WCSROOT, "include"))

    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', 'unit_list_proxy.c', 'util.c',
        'wcslib_wrap.c', 'wcslib_tabprm_wrap.c'
    ]
    cfg['sources'].extend(join(WCSROOT, 'src', x) for x in astropy_wcs_files)

    cfg['sources'] = [str(x) for x in cfg['sources']]
    cfg = dict((str(key), val) for key, val in cfg.items())

    # Copy over header files from WCSLIB into the installed version of Astropy
    # so that other Python packages can write extensions that link to it. We
    # do the copying here then include the data in [options.package_data] in
    # the setup.cfg file

    wcslib_headers = [
        'cel.h',
        'lin.h',
        'prj.h',
        'spc.h',
        'spx.h',
        'tab.h',
        'wcs.h',
        'wcserr.h',
        'wcsmath.h',
        'wcsprintf.h',
    ]

    if not setup_helpers.use_system_library('wcslib'):
        for header in wcslib_headers:
            source = join('cextern', 'wcslib', 'C', header)
            dest = join('astropy', 'wcs', 'include', 'wcslib', header)
            if newer_group([source], dest, 'newer'):
                shutil.copy(source, dest)

    return [Extension('astropy.wcs._wcs', **cfg)]
예제 #6
0
def get_extensions():
    ROOT = os.path.relpath(os.path.dirname(__file__))

    cfg = setup_helpers.DistutilsExtensionArgs()
    cfg['include_dirs'].append('numpy')

    sources = [str(os.path.join(ROOT, 'src', 'math_util.c'))]

    if (not setup_helpers.use_system_library('qd') or sys.platform == 'win32'):
        qd_library_path = os.path.join(ROOT, '..', 'cextern', 'qd-library')
        qd_library_c_path = os.path.join(qd_library_path, 'src')
        qd_library_include_path = os.path.join(qd_library_path, 'include')

        qd_sources = [
            'bits.cpp', 'c_dd.cpp', 'dd_real.cpp', 'dd_const.cpp', 'fpu.cpp',
            'util.cpp'
        ]

        sources.extend(
            [str(os.path.join(qd_library_c_path, x)) for x in qd_sources])
        cfg['include_dirs'].extend(
            [qd_library_include_path,
             str(os.path.join(ROOT, 'src'))])
        cfg['libraries'].append('m')
    else:
        cfg.update(setup_helpers.pkg_config([], ['qd', 'm'], 'qd-config'))

    return [Extension(str('spherical_geometry.math_util'), sources, **cfg)]
예제 #7
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:
            # 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-declaration-after-statement'
            ])

        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)]
예제 #8
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:
            # 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-declaration-after-statement'
            ])

        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)]
예제 #9
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'])
예제 #10
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)
예제 #11
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:
            # 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-declaration-after-statement",
                ]
            )

        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)]
예제 #12
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)
예제 #13
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,
    ]
예제 #14
0
def get_package_data():
    # Installs the testing data files
    api_files = [
        "astropy_wcs.h",
        "astropy_wcs_api.h",
        "distortion.h",
        "isnan.h",
        "pipeline.h",
        "pyutil.h",
        "sip.h",
        "util.h",
        "wcsconfig.h",
    ]
    api_files = [join("include", "astropy_wcs", x) for x in api_files]
    api_files.append(join("include", "astropy_wcs_api.h"))

    wcslib_headers = [
        "cel.h",
        "lin.h",
        "prj.h",
        "spc.h",
        "spx.h",
        "tab.h",
        "wcs.h",
        "wcserr.h",
        "wcsmath.h",
        "wcsprintf.h",
    ]
    if not setup_helpers.use_system_library("wcslib"):
        for header in wcslib_headers:
            source = join("cextern", "wcslib", "C", header)
            dest = join("astropy", "wcs", "include", "wcslib", header)
            if newer_group([source], dest, "newer"):
                shutil.copy(source, dest)
            api_files.append(join("include", "wcslib", header))

    return {
        str("astropy.wcs.tests"): [
            "data/*.hdr",
            "data/*.fits",
            "data/*.txt",
            "maps/*.hdr",
            "spectra/*.hdr",
            "extension/*.c",
        ],
        str("astropy.wcs"): api_files,
    }
예제 #15
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, ]
예제 #16
0
def get_package_data():
    # Installs the testing data files
    api_files = [
        'astropy_wcs.h',
        'astropy_wcs_api.h',
        'distortion.h',
        'isnan.h',
        'pipeline.h',
        'pyutil.h',
        'sip.h',
        'util.h',
        'wcsconfig.h',
        ]
    api_files = [join('include', 'astropy_wcs', x) for x in api_files]
    api_files.append(join('include', 'astropy_wcs_api.h'))

    wcslib_headers = [
        'cel.h',
        'lin.h',
        'prj.h',
        'spc.h',
        'spx.h',
        'tab.h',
        'wcs.h',
        'wcserr.h',
        'wcsmath.h',
        'wcsprintf.h',
        ]
    if not setup_helpers.use_system_library('wcslib'):
        for header in wcslib_headers:
            source = join('cextern', 'wcslib', 'C', header)
            dest = join('astropy', 'wcs', 'include', 'wcslib', header)
            if newer_group([source], dest, 'newer'):
                shutil.copy(source, dest)
            api_files.append(join('include', 'wcslib', header))

    return {
        str('astropy.wcs.tests'): ['data/*.hdr', 'data/*.fits',
                                   'data/*.txt', 'data/*.fits.gz',
                                   'maps/*.hdr', 'spectra/*.hdr',
                                   'extension/*.c'],
        str('astropy.wcs'): api_files,
        str('astropy.wcs.wcsapi'): ['ucds.txt']
    }
def get_package_data():
    # Installs the testing data files
    api_files = [
        'astropy_wcs.h',
        'astropy_wcs_api.h',
        'distortion.h',
        'isnan.h',
        'pipeline.h',
        'pyutil.h',
        'sip.h',
        'util.h',
        'wcsconfig.h',
    ]
    api_files = [join('include', 'astropy_wcs', x) for x in api_files]
    api_files.append(join('include', 'astropy_wcs_api.h'))

    wcslib_headers = [
        'cel.h',
        'lin.h',
        'prj.h',
        'spc.h',
        'spx.h',
        'tab.h',
        'wcs.h',
        'wcserr.h',
        'wcsmath.h',
        'wcsprintf.h',
    ]
    if not setup_helpers.use_system_library('wcslib'):
        for header in wcslib_headers:
            source = join('cextern', 'wcslib', 'C', header)
            dest = join('astropy', 'wcs', 'include', 'wcslib', header)
            if newer_group([source], dest, 'newer'):
                shutil.copy(source, dest)
            api_files.append(join('include', 'wcslib', header))

    return {
        str('astropy.wcs.tests'): [
            'data/*.hdr', 'data/*.fits', 'data/*.txt', 'data/*.fits.gz',
            'maps/*.hdr', 'spectra/*.hdr', 'extension/*.c'
        ],
        str('astropy.wcs'):
        api_files,
    }
예제 #18
0
def get_extensions():
    sources = [os.path.join(TIMEROOT, "erfa_time.pyx")]
    include_dirs = ['numpy']
    libraries = []

    if setup_helpers.use_system_library('erfa'):
        libraries.append('erfa')
    else:
        sources.append("cextern/erfa/erfa.c")
        include_dirs.append('cextern/erfa')

    time_ext = Extension(
        name="astropy.time.erfa_time",
        sources=sources,
        include_dirs=include_dirs,
        libraries=libraries,
        language="c",)

    return [time_ext]
예제 #19
0
def get_extensions():
    sources = [os.path.join(TIMEROOT, "erfa_time.pyx")]
    include_dirs = ['numpy']
    libraries = []

    if setup_helpers.use_system_library('erfa'):
        libraries.append('erfa')
    else:
        sources.append("cextern/erfa/erfa.c")
        include_dirs.append('cextern/erfa')

    time_ext = Extension(
        name="astropy.time.erfa_time",
        sources=sources,
        include_dirs=include_dirs,
        libraries=libraries,
        language="c",
    )

    return [time_ext]
예제 #20
0
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]
예제 #21
0
def get_libFTR_extensions(filename, modulename, pattern="*.pyx", **kwargs):
    """docstring for get_libFTR_extensions"""
    
    this_directory = os.path.dirname(filename)
    this_name = modulename.split(".")[:-1]
    
    include_directory = get_libFTR_include_directory()
    libraries = ['fftw3', 'fftw3_threads', 'pthread']
    
    extension_args = {
        'include_dirs' : ['numpy', include_directory ],
        'libraries' : libraries,
        'sources' : []
    }
    extension_args.update(kwargs)
    
    extensions = []
    
    for component in glob.iglob(os.path.join(this_directory, pattern)):
        # Component name and full module name.
        this_extension_args = copy.deepcopy(extension_args)
        cname = os.path.splitext(os.path.basename(component))[0]
        if cname.startswith("_"):
            cname = cname[1:]
            name = ".".join(this_name + ["_{0:s}".format(cname)])
        else:
            name = ".".join(this_name + [cname])
        this_extension_args['sources'].append(component)
        
        # Library checks.
        if setup_helpers.use_system_library('ftr'):
            this_extension_args['libraries'].append('ftr')
        else:
            this_extension_args['sources'].extend(glob.glob(os.path.join(include_directory, "*" + cname + "*.c")))
        # Extension object.
        extension = Extension(name, **this_extension_args)
        extensions.append(extension)
    
    return extensions
예제 #22
0
def get_extensions():
    sources = [os.path.join(ERFAPKGDIR, "erfa.pyx")]
    include_dirs = ['numpy']
    libraries = []

    if setup_helpers.use_system_library('erfa'):
        libraries.append('erfa')
    else:
        # get all of the .c files in the cextern/erfa directory
        erfafns = os.listdir(ERFA_SRC)
        sources.extend(['cextern/erfa/'+fn for fn in erfafns if fn.endswith('.c')])

        include_dirs.append('cextern/erfa')

    erfa_ext = Extension(
        name="astropy.erfa._erfa",
        sources=sources,
        include_dirs=include_dirs,
        libraries=libraries,
        language="c",)

    return [erfa_ext]
예제 #23
0
def get_extensions():
    from astropy.version import debug

    generate_c_docstrings()

    ######################################################################
    # DISTUTILS SETUP
    cfg = setup_helpers.DistutilsExtensionArgs()

    cfg["include_dirs"].extend(["numpy", join(WCSROOT, "include")])
    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()

        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",
            "dis.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",
        ]
        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"]))

    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",
        "unit_list_proxy.c",
        "util.c",
        "wcslib_wrap.c",
        "wcslib_tabprm_wrap.c",
        "wcslib_wtbarr_wrap.c",
    ]
    cfg["sources"].extend(join(WCSROOT, "src", x) for x in astropy_wcs_files)

    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))

    cfg["sources"] = [str(x) for x in cfg["sources"]]

    cfg = dict((str(key), val) for key, val in six.iteritems(cfg))

    return [Extension(str("astropy.wcs._wcs"), **cfg)]
예제 #24
0
def get_extensions():
    from astropy.version import debug

    generate_c_docstrings()

    ######################################################################
    # DISTUTILS SETUP
    cfg = setup_helpers.DistutilsExtensionArgs()

    cfg['include_dirs'].extend(['numpy', join(WCSROOT, "include")])
    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()

        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',
            'dis.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']
        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']))

    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',
        'unit_list_proxy.c',
        'util.c',
        'wcslib_wrap.c',
        'wcslib_tabprm_wrap.c',
        'wcslib_wtbarr_wrap.c']
    cfg['sources'].extend(join(WCSROOT, 'src', x) for x in astropy_wcs_files)

    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))

    cfg['sources'] = [str(x) for x in cfg['sources']]

    cfg = dict((str(key), val) for key, val in six.iteritems(cfg))

    return [Extension(str('astropy.wcs._wcs'), **cfg)]
예제 #25
0
def get_extensions():
    from astropy.version import debug

    generate_c_docstrings()

    ######################################################################
    # DISTUTILS SETUP
    cfg = setup_helpers.DistutilsExtensionArgs()

    cfg['include_dirs'].extend(['numpy', join(WCSROOT, "include")])
    cfg['define_macros'].extend([('ECHO', None), ('WCSTRIG_MACRO', None),
                                 ('ASTROPY_WCS_BUILD', None),
                                 ('_GNU_SOURCE', None),
                                 ('WCSVERSION', WCSVERSION)])

    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'
        ]
        cfg['sources'].extend(join(wcslib_cpath, x) for x in wcslib_files)
        cfg['include_dirs'].append(wcslib_cpath)
    else:
        cfg.update(setup_helpers.pkg_config(['wcslib'], ['wcs']))

    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', 'unit_list_proxy.c', 'util.c',
        'wcslib_wrap.c', 'wcslib_tabprm_wrap.c', 'wcslib_wtbarr_wrap.c'
    ]
    cfg['sources'].extend(join(WCSROOT, 'src', x) for x in astropy_wcs_files)

    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))

    cfg['sources'] = [str(x) for x in cfg['sources']]

    cfg = dict((str(key), val) for key, val in six.iteritems(cfg))

    return [Extension(str('astropy.wcs._wcs'), **cfg)]