Beispiel #1
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'])

        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)]
Beispiel #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)]
Beispiel #3
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'
            ])

        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)]
Beispiel #4
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)]
Beispiel #5
0
def get_extensions():
    # 'numpy' will be replaced with the proper path to the numpy includes
    include_dirs = ['numpy']
    library_dirs = []
    libraries = []
    source_files = [os.path.relpath(fname) for fname in
                    glob(os.path.join(os.path.dirname(__file__),
                                      'src', '*.c'))]
    extra_compile_args = []

    if not setup_helpers.use_system_library('cfitsio'):
        if setup_helpers.get_compiler_option() == 'msvc':
            # These come from the CFITSIO vcc makefile
            extra_compile_args = [
                    '/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
            extra_compile_args = ['-Wno-unused-variable', '-Wno-parentheses',
                                  '-Wno-uninitialized', '-Wno-format',
                                  '-Wno-strict-prototypes', '-Wno-unused',
                                  '-Wno-comments', '-Wno-switch']

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

    return [
        Extension(
            'astropy.io.fits.compression',
            source_files,
            include_dirs=include_dirs,
            extra_compile_args=extra_compile_args,
            libraries=libraries,
            library_dirs=library_dirs)
    ]
Beispiel #6
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]
Beispiel #7
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]
Beispiel #8
0
def get_extensions(build_type="release"):
    XML_DIR = "astropy/utils/xml/src"

    source_files = [join(XML_DIR, "iterparse.c")]
    include_dirs = []
    extra_link_args = []
    defines = []
    libraries = []
    library_dirs = []

    if setup_helpers.use_system_library("expat"):
        setup_helpers.pkg_config(["expat"], ["expat"], include_dirs, library_dirs, libraries)
    else:
        EXPAT_DIR = "cextern/expat/lib"
        source_files.extend([join(EXPAT_DIR, fn) for fn in ["xmlparse.c", "xmlrole.c", "xmltok.c", "xmltok_impl.c"]])
        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.
            extra_link_args.append("-Wl,--version-script={0}".format(join(XML_DIR, "iterparse.map")))
        defines = [("HAVE_EXPAT_CONFIG_H", 1)]
        if sys.byteorder == "big":
            defines.append(("BYTEORDER", "4321"))
        else:
            defines.append(("BYTEORDER", "1234"))
        if sys.platform != "win32":
            defines.append(("HAVE_UNISTD_H", None))

    return [
        Extension(
            "astropy.utils.xml._iterparser",
            source_files,
            define_macros=defines,
            include_dirs=include_dirs,
            library_dirs=library_dirs,
            libraries=libraries,
            extra_link_args=extra_link_args,
        )
    ]
Beispiel #9
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_units_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)]
Beispiel #10
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_units_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))

    return [Extension('astropy.wcs._wcs', **cfg)]
Beispiel #11
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_units_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))

    return [Extension("astropy.wcs._wcs", **cfg)]
Beispiel #12
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)]