Beispiel #1
0
 def link(self,
          target_desc,
          objects,
          output_filename,
          output_dir=None,
          libraries=None,
          library_dirs=None,
          runtime_library_dirs=None,
          export_symbols=None,
          debug=0,
          extra_preargs=None,
          extra_postargs=None,
          build_temp=None,
          target_lang=None):
     export_symbols=None
     old_MSVCCompiler.link(self,
          target_desc,
          objects,
          output_filename,
          output_dir,
          libraries,
          library_dirs,
          runtime_library_dirs,
          export_symbols,
          debug,
          extra_preargs,
          extra_postargs,
          build_temp,
          target_lang)
Beispiel #2
0
 def initialize(self, plat_name=None):
     MSVCCompiler.initialize(self, plat_name)
     self.cc = self.find_exe("icl.exe")
     self.lib = self.find_exe("xilib")
     self.linker = self.find_exe("xilink")
     self.compile_options = ['/nologo', '/O3', '/MD', '/W3',
                             '/Qstd=c99']
     self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3',
                                   '/Qstd=c99', '/Z7', '/D_DEBUG']
Beispiel #3
0
    def compile_wrapper_python26(self):
        # For Python-2.6 we build with Visual Studio; trying to get a
        # MingW32-built .exe to load the extensions we bundle for Python-2.6
        # seems very difficult. We hope that our version of Visual Studio
        # was close enough to the version that Python is built with so
        # that if Python runs, we run.
        #
        # We use some distutils internals to locate the Visual Studio
        # command line tools
        #
        from distutils.msvc9compiler import MSVCCompiler
        compiler = MSVCCompiler()
        # This looks for the tools and then adds them to os.environ['Path']
        compiler.initialize()

        python_topdir = os.path.dirname(os.path.dirname(shutil.__file__))
        python_include = os.path.join(python_topdir, "include")
        python_lib = os.path.join(python_topdir, "libs")

        wrapper_c = os.path.join(self.topdir, "tools", "build_msi", "wrapper.c")

        wrapper_rc = os.path.join(self.tempdir, "wrapper.rc")
        f = open(wrapper_rc, "w")
        f.write("""LANGUAGE 0, 0
100	 ICON	%s
""" % os.path.join(self.treedir, "Reinteract.ico"))
        f.close()

        # We can use distutils to do the basic compilation
        objects = compiler.compile([wrapper_c, wrapper_rc],
                                   output_dir=self.tempdir, include_dirs=[python_include])

        # But have to do the linking a bit more manually since distutils
        # doesn't know how to handle creating .exe files
        wrapper = os.path.join(self.tempdir,  "Reinteract.exe")
        manifest = os.path.join(self.tempdir,  "Reinteract.exe.manifest")
        extra_libs = [
            'user32.lib', # For MessageBox
        ]
        check_call([compiler.linker,
                    "/MANIFEST",
                    "/MANIFESTFILE:" + manifest,
                    "/LIBPATH:" + python_lib,
                    "/OUT:" + wrapper]
                   + objects + extra_libs)

        # Embed the manifest into the executable
        check_call(['mt.exe',
                    '-manifest', manifest,
                    '-outputresource:' + wrapper + ';1'])

        self.add_file(wrapper, 'bin', feature='core')
    def test_remove_entire_manifest(self):
        from distutils.msvc9compiler import MSVCCompiler
        tempdir = self.mkdtemp()
        manifest = os.path.join(tempdir, 'manifest')
        f = open(manifest, 'w')
        try:
            f.write(_MANIFEST_WITH_ONLY_MSVC_REFERENCE)
        finally:
            f.close()

        compiler = MSVCCompiler()
        got = compiler._remove_visual_c_ref(manifest)
        self.assertIs(got, None)
    def initialize(self, plat_name=None):
        # The 'lib' and 'include' variables may be overwritten
        # by MSVCCompiler.initialize, so save them for later merge.
        environ_lib = os.getenv('lib')
        environ_include = os.getenv('include')
        _MSVCCompiler.initialize(self, plat_name)

        # Merge current and previous values of 'lib' and 'include'
        os.environ['lib'] = _merge(environ_lib, os.environ['lib'])
        os.environ['include'] = _merge(environ_include, os.environ['include'])

        # msvc9 building for 32 bits requires SSE2 to work around a
        # compiler bug.
        if platform_bits == 32:
            self.compile_options += ['/arch:SSE2']
            self.compile_options_debug += ['/arch:SSE2']
    def test_remove_visual_c_ref(self):
        from distutils.msvc9compiler import MSVCCompiler
        tempdir = self.mkdtemp()
        manifest = os.path.join(tempdir, 'manifest')
        f = open(manifest, 'w')
        try:
            f.write(_MANIFEST_WITH_MULTIPLE_REFERENCES)
        finally:
            f.close()

        compiler = MSVCCompiler()
        compiler._remove_visual_c_ref(manifest)
        f = open(manifest)
        try:
            content = '\n'.join([ line.rstrip() for line in f.readlines() ])
        finally:
            f.close()

        self.assertEqual(content, _CLEANED_MANIFEST)
    def test_remove_visual_c_ref(self):
        from distutils.msvc9compiler import MSVCCompiler
        tempdir = self.mkdtemp()
        manifest = os.path.join(tempdir, 'manifest')
        f = open(manifest, 'w')
        f.write(_MANIFEST)
        f.close()

        compiler = MSVCCompiler()
        compiler._remove_visual_c_ref(manifest)

        # see what we got
        f = open(manifest)
        # removing trailing spaces
        content = '\n'.join([line.rstrip() for line in f.readlines()])
        f.close()

        # makes sure the manifest was properly cleaned
        self.assertEquals(content, _CLEANED_MANIFEST)
    def test_remove_visual_c_ref(self):
        from distutils.msvc9compiler import MSVCCompiler

        tempdir = self.mkdtemp()
        manifest = os.path.join(tempdir, "manifest")
        f = open(manifest, "w")
        try:
            f.write(_MANIFEST_WITH_MULTIPLE_REFERENCES)
        finally:
            f.close()

        compiler = MSVCCompiler()
        compiler._remove_visual_c_ref(manifest)

        # see what we got
        f = open(manifest)
        try:
            # removing trailing spaces
            content = "\n".join([line.rstrip() for line in f.readlines()])
        finally:
            f.close()

        # makes sure the manifest was properly cleaned
        self.assertEqual(content, _CLEANED_MANIFEST)
 def __init__(self, verbose=0, dry_run=0, force=0):
     _MSVCCompiler.__init__(self, verbose, dry_run, force)
Beispiel #10
0
 def library_dir_option (self, dir):
     dir = dir.replace('\\', '\\\\')
     return old_MSVCCompiler.library_dir_option(self, dir)
Beispiel #11
0
 def __init__(self, verbose=0, dry_run=0, force=0):
     MSVCCompiler.__init__(self, verbose, dry_run, force)
     version_match = simple_version_match(start='Intel\(R\).*?64,')
     self.__version = version_match
Beispiel #12
0
import os
import re
import sys


if hasattr(sys, 'pypy_version_info'):
    ext_modules = []
else:
    extra_objects = []
    if sys.platform == 'win32':
        # This is a hack because msvc9compiler doesn't support asm files
        # http://bugs.python.org/issue7546

        # Initialize compiler
        from distutils.msvc9compiler import MSVCCompiler
        cc = MSVCCompiler()
        cc.initialize()
        del cc

        if '32 bit' in sys.version:
            extra_objects = ['src/switch_x86_msvc.obj']
            os.system('ml /nologo /c /Fo src\switch_x86_msvc.obj src\switch_x86_msvc.asm')
        else:
            extra_objects = ['src/switch_x64_msvc.obj']
            os.system('ml64 /nologo /c /Fo src\switch_x64_msvc.obj src\switch_x64_msvc.asm')

    ext_modules  = [Extension('fibers._cfibers',
                              sources=glob.glob('src/*.c'),
                              extra_objects=extra_objects,
                             )]
Beispiel #13
0
 def library_dir_option(self, dir):
     dir = dir.replace("\\", "\\\\")
     return old_MSVCCompiler.library_dir_option(self, dir)
Beispiel #14
0
def cdecimal_ext(machine):
    depends = [
        'basearith.h', 'bits.h', 'constants.h', 'convolute.h', 'crt.h',
        'difradix2.h', 'docstrings.h', 'fnt.h', 'fourstep.h', 'io.h',
        'memory.h', 'mpdecimal.h', 'mpdecimal32.h', 'mpdecimal64.h',
        'mptypes.h', 'numbertheory.h', 'sixstep.h', 'transpose.h',
        'typearith.h', 'umodarith.h'
    ]
    sources = [
        'basearith.c', 'constants.c', 'context.c', 'convolute.c',
        'crt.c', 'difradix2.c', 'fnt.c', 'fourstep.c', 'io.c', 'memory.c',
        'mpdecimal.c', 'numbertheory.c', 'sixstep.c', 'transpose.c'
    ]
    sources.append('cdecimal2.c' if PY_MAJOR == 2 else 'cdecimal3.c')
    extra_compile_args = []
    extra_link_args = []
    extra_objects = []


    if SYSTEM == 'win32':
        define_macros.append(('_CRT_SECURE_NO_WARNINGS', '1'))
        if not machine: # command line option
            if ARCH == '64bit':
                machine = 'x64'
            else:
                machine = 'ppro'

        if machine == 'x64':
            if not (PY_MAJOR == 2 and PY_MINOR == 5):
                # set the build environment for ml64
                from distutils.msvc9compiler import MSVCCompiler
                cc = MSVCCompiler()
                cc.initialize()
                del cc
            define_macros.extend([('CONFIG_64', '1'), ('MASM', '1')])
            extra_objects = ['vcdiv64.obj']
            os.system("ml64 /c /Cx vcdiv64.asm")
            copy2("mpdecimal64vc.h", "mpdecimal.h")
        elif machine == 'ansi64':
            define_macros.extend([('CONFIG_64', '1'), ('ANSI', '1')])
            copy2("mpdecimal64vc.h", "mpdecimal.h")
        elif machine == 'ppro':
            define_macros.extend([('CONFIG_32', '1'), ('PPRO', '1'),
                                  ('MASM', '1')])
            copy2("mpdecimal32vc.h", "mpdecimal.h")
        elif machine == 'ansi32':
            define_macros.extend([('CONFIG_32', '1'), ('ANSI', '1')])
            copy2("mpdecimal32vc.h", "mpdecimal.h")
        elif machine == 'ansi-legacy':
            define_macros.extend([('CONFIG_32', '1'), ('ANSI', '1'),
                                  ('LEGACY_COMPILER', '1')])
            copy2("mpdecimal32vc.h", "mpdecimal.h")
        else:
            err_exit("unsupported machine: %s" % machine)

    else:
        cc = sysconfig.get_config_var('CC')
        py_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T')
        if py_size_t != 8 and py_size_t != 4:
            err_exit("unsupported architecture: sizeof(size_t) must be 8 or 4")

        depends.append('config.h')
        config_vars = configure(machine, cc, py_size_t)
        if config_vars['SIZEOF_SIZE_T'] != 8 and \
           config_vars['SIZEOF_SIZE_T'] != 4:
            err_exit("unsupported architecture: sizeof(size_t) must be 8 or 4")

        if not machine and py_size_t != config_vars['SIZEOF_SIZE_T']:
            if py_size_t == 8:
                print(MULTILIB_ERR_64)
            elif py_size_t == 4:
                print(MULTILIB_ERR_32)
            sys.exit(1)

        if not machine:
            if config_vars['HAVE_GCC_ASM_FOR_X64']:
                machine = 'x64'
            elif config_vars['HAVE_UINT128_T']:
                machine = 'uint128'
            elif config_vars['HAVE_GCC_ASM_FOR_X87']:
                machine = 'ppro'

        if machine == 'universal':
            add_macros = [('UNIVERSAL', '1')]
        elif py_size_t == 8:
            if machine == 'x64':
                add_macros = [('CONFIG_64', '1'), ('ASM', '1')]
            elif machine == 'uint128':
                add_macros = [('CONFIG_64', '1'), ('ANSI', '1'),
                              ('HAVE_UINT128_T', '1')]
            else:
                add_macros = [('CONFIG_64', '1'), ('ANSI', '1')]
        else:
            if machine == 'ppro' and ('gcc' in cc or 'clang' in cc):
                # suncc: register allocator cannot deal with the inline asm.
                # icc >= 11.0 works as well.
                add_macros = [('CONFIG_32', '1'), ('PPRO', '1'), ('ASM', '1')]
                if config_vars['HAVE_IPA_PURE_CONST_BUG']:
                    # Some versions of gcc miscompile inline asm:
                    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
                    # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
                    extra_compile_args.extend(['-fno-ipa-pure-const'])
            else: # ansi32
                add_macros = [('CONFIG_32', '1'), ('ANSI', '1')]
                if machine == 'ansi-legacy':
                    add_macros.append(('LEGACY_COMPILER', '1'))

        # Uncomment for warnings:
        # extra_compile_args.extend(['-Wall', '-W', '-Wno-missing-field-initializers'])

        # Uncomment for a debug build:
        # extra_compile_args.extend(['-O0', '-g'])

        if os.environ.get("CFLAGS"):
            # Distutils drops -fno-strict-aliasing if CFLAGS are set:
            # http://bugs.python.org/issue10847
            if 'xlc' in cc:
                extra_compile_args.append('-qnoansialias')
            else:
                extra_compile_args.append('-fno-strict-aliasing')

        define_macros.extend(add_macros)

        if config_vars['HAVE_GLIBC_MEMMOVE_BUG']:
            # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
            # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
            undef_macros.append('_FORTIFY_SOURCE')

    ext = Extension (
        'cdecimal',
        define_macros=define_macros,
        undef_macros=undef_macros,
        depends=depends,
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
        sources=sources,
        extra_objects=extra_objects
    )
    return ext
Beispiel #15
0
def cdecimal_ext(machine):
    depends = [
        'basearith.h', 'bits.h', 'constants.h', 'convolute.h', 'crt.h',
        'difradix2.h', 'docstrings.h', 'fnt.h', 'fourstep.h', 'io.h',
        'memory.h', 'mpdecimal.h', 'mpdecimal32.h', 'mpdecimal64.h',
        'mptypes.h', 'numbertheory.h', 'sixstep.h', 'transpose.h',
        'typearith.h', 'umodarith.h'
    ]
    sources = [
        'basearith.c', 'constants.c', 'context.c', 'convolute.c', 'crt.c',
        'difradix2.c', 'fnt.c', 'fourstep.c', 'io.c', 'memory.c',
        'mpdecimal.c', 'numbertheory.c', 'sixstep.c', 'transpose.c'
    ]
    sources.append('cdecimal2.c' if PY_MAJOR == 2 else 'cdecimal3.c')
    extra_compile_args = []
    extra_link_args = []
    extra_objects = []

    if SYSTEM == 'win32':
        define_macros.append(('_CRT_SECURE_NO_WARNINGS', '1'))
        if not machine:  # command line option
            if ARCH == '64bit':
                machine = 'x64'
            else:
                machine = 'ppro'

        if machine == 'x64':
            if not (PY_MAJOR == 2 and PY_MINOR == 5):
                # set the build environment for ml64
                from distutils.msvc9compiler import MSVCCompiler
                cc = MSVCCompiler()
                cc.initialize()
                del cc
            define_macros.extend([('CONFIG_64', '1'), ('MASM', '1')])
            extra_objects = ['vcdiv64.obj']
            os.system("ml64 /c /Cx vcdiv64.asm")
            copy2("mpdecimal64vc.h", "mpdecimal.h")
        elif machine == 'ansi64':
            define_macros.extend([('CONFIG_64', '1'), ('ANSI', '1')])
            copy2("mpdecimal64vc.h", "mpdecimal.h")
        elif machine == 'ppro':
            define_macros.extend([('CONFIG_32', '1'), ('PPRO', '1'),
                                  ('MASM', '1')])
            copy2("mpdecimal32vc.h", "mpdecimal.h")
        elif machine == 'ansi32':
            define_macros.extend([('CONFIG_32', '1'), ('ANSI', '1')])
            copy2("mpdecimal32vc.h", "mpdecimal.h")
        elif machine == 'ansi-legacy':
            define_macros.extend([('CONFIG_32', '1'), ('ANSI', '1'),
                                  ('LEGACY_COMPILER', '1')])
            copy2("mpdecimal32vc.h", "mpdecimal.h")
        else:
            err_exit("unsupported machine: %s" % machine)

    else:
        cc = sysconfig.get_config_var('CC')
        py_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T')
        if py_size_t != 8 and py_size_t != 4:
            err_exit("unsupported architecture: sizeof(size_t) must be 8 or 4")

        depends.append('config.h')
        config_vars = configure(machine, cc, py_size_t)
        if config_vars['SIZEOF_SIZE_T'] != 8 and \
           config_vars['SIZEOF_SIZE_T'] != 4:
            err_exit("unsupported architecture: sizeof(size_t) must be 8 or 4")

        if not machine and py_size_t != config_vars['SIZEOF_SIZE_T']:
            if py_size_t == 8:
                print(MULTILIB_ERR_64)
            elif py_size_t == 4:
                print(MULTILIB_ERR_32)
            sys.exit(1)

        if not machine:
            if config_vars['HAVE_GCC_ASM_FOR_X64']:
                machine = 'x64'
            elif config_vars['HAVE_UINT128_T']:
                machine = 'uint128'
            elif config_vars['HAVE_GCC_ASM_FOR_X87']:
                machine = 'ppro'

        if machine == 'universal':
            add_macros = [('UNIVERSAL', '1')]
        elif py_size_t == 8:
            if machine == 'x64':
                add_macros = [('CONFIG_64', '1'), ('ASM', '1')]
            elif machine == 'uint128':
                add_macros = [('CONFIG_64', '1'), ('ANSI', '1'),
                              ('HAVE_UINT128_T', '1')]
            else:
                add_macros = [('CONFIG_64', '1'), ('ANSI', '1')]
        else:
            if machine == 'ppro' and ('gcc' in cc or 'clang' in cc):
                # suncc: register allocator cannot deal with the inline asm.
                # icc >= 11.0 works as well.
                add_macros = [('CONFIG_32', '1'), ('PPRO', '1'), ('ASM', '1')]
                if config_vars['HAVE_IPA_PURE_CONST_BUG']:
                    # Some versions of gcc miscompile inline asm:
                    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
                    # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
                    extra_compile_args.extend(['-fno-ipa-pure-const'])
            else:  # ansi32
                add_macros = [('CONFIG_32', '1'), ('ANSI', '1')]
                if machine == 'ansi-legacy':
                    add_macros.append(('LEGACY_COMPILER', '1'))

        # Uncomment for warnings:
        # extra_compile_args.extend(['-Wall', '-W', '-Wno-missing-field-initializers'])

        # Uncomment for a debug build:
        # extra_compile_args.extend(['-O0', '-g'])

        if os.environ.get("CFLAGS"):
            # Distutils drops -fno-strict-aliasing if CFLAGS are set:
            # http://bugs.python.org/issue10847
            if 'xlc' in cc:
                extra_compile_args.append('-qnoansialias')
            else:
                extra_compile_args.append('-fno-strict-aliasing')

        define_macros.extend(add_macros)

        if config_vars['HAVE_GLIBC_MEMMOVE_BUG']:
            # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
            # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
            undef_macros.append('_FORTIFY_SOURCE')

    ext = Extension('cdecimal',
                    define_macros=define_macros,
                    undef_macros=undef_macros,
                    depends=depends,
                    extra_compile_args=extra_compile_args,
                    extra_link_args=extra_link_args,
                    sources=sources,
                    extra_objects=extra_objects)
    return ext
 def manifest_setup_ldargs(self, output_filename, build_temp, ld_args):
     ld_args.append('/MANIFEST')
     _MSVCCompiler.manifest_setup_ldargs(self, output_filename,
                                         build_temp, ld_args)
Beispiel #17
0
def gumath_extensions():
    add_include_dirs = [
        ".", "libgumath", "ndtypes/python/ndtypes", "xnd/python/xnd"
    ] + INCLUDES
    add_library_dirs = ["libgumath", "ndtypes/libndtypes", "xnd/libxnd"] + LIBS
    add_depends = []
    config_vars = {}

    if sys.platform == "win32":
        add_libraries = [
            "libndtypes-0.2.0dev3.dll", "libxnd-0.2.0dev3.dll",
            "libgumath-0.2.0dev3.dll"
        ]
        add_extra_compile_args = [
            "/DNDT_IMPORT", "/DXND_IMPORT", "/DGM_IMPORT"
        ]
        add_extra_link_args = []
        add_runtime_library_dirs = []

        if BUILD_ALL:
            from distutils.msvc9compiler import MSVCCompiler
            MSVCCompiler().initialize()
            os.chdir("vcbuild")
            os.environ['LIBNDTYPESINCLUDE'] = os.path.normpath(
                CONFIGURE_INCLUDES[0])
            os.environ['LIBNDTYPESDIR'] = os.path.normpath(CONFIGURE_LIBS[0])
            os.environ['LIBXNDINCLUDE'] = os.path.normpath(
                CONFIGURE_INCLUDES[1])
            os.environ['LIBXNDDIR'] = os.path.normpath(CONFIGURE_LIBS[1])
            if ARCH == "64bit":
                os.system("vcbuild64.bat")
            else:
                os.system("vcbuild32.bat")
            os.chdir("..")
    else:
        if BUILD_ALL:
            cflags = '"-I%s -I%s"' % tuple(CONFIGURE_INCLUDES)
            ldflags = '"-L%s -L%s"' % tuple(CONFIGURE_LIBS)
            make = "make -j%d" % int(PARALLEL) if PARALLEL else "make"
            os.system("./configure CFLAGS=%s LDFLAGS=%s && %s" %
                      (cflags, ldflags, make))

        config_vars = get_config_vars()

        add_extra_compile_args = [
            "-Wextra", "-Wno-missing-field-initializers", "-std=c11"
        ]
        if sys.platform == "darwin":
            add_libraries = ["ndtypes", "xnd", "gumath"]
            add_extra_link_args = ["-Wl,-rpath,@loader_path"]
            add_runtime_library_dirs = []
        else:
            add_libraries = [
                ":%s" % LIBNDTYPES,
                ":%s" % LIBXND,
                ":%s" % LIBSHARED
            ]
            add_extra_link_args = []
            add_runtime_library_dirs = ["$ORIGIN"]

        if config_vars["HAVE_CUDA"]:
            add_libraries += ["cudart"]

            for d in [
                    "/usr/cuda/lib", "/usr/cuda/lib64", "/usr/local/cuda/lib/",
                    "/usr/local/cuda/lib64"
            ]:
                if os.path.isdir(d):
                    add_library_dirs.append(d)

    def gumath_ext():
        sources = ["python/gumath/_gumath.c"]

        return Extension("gumath._gumath",
                         include_dirs=add_include_dirs,
                         library_dirs=add_library_dirs,
                         depends=add_depends,
                         sources=sources,
                         libraries=add_libraries,
                         extra_compile_args=add_extra_compile_args,
                         extra_link_args=add_extra_link_args,
                         runtime_library_dirs=add_runtime_library_dirs)

    def functions_ext():
        sources = ["python/gumath/functions.c"]

        return Extension("gumath.functions",
                         include_dirs=add_include_dirs,
                         library_dirs=add_library_dirs,
                         depends=add_depends,
                         sources=sources,
                         libraries=add_libraries,
                         extra_compile_args=add_extra_compile_args,
                         extra_link_args=add_extra_link_args,
                         runtime_library_dirs=add_runtime_library_dirs)

    def cuda_ext():
        sources = ["python/gumath/cuda.c"]

        return Extension("gumath.cuda",
                         include_dirs=add_include_dirs,
                         library_dirs=add_library_dirs,
                         depends=add_depends,
                         sources=sources,
                         libraries=add_libraries,
                         extra_compile_args=add_extra_compile_args,
                         extra_link_args=add_extra_link_args,
                         runtime_library_dirs=add_runtime_library_dirs)

    def examples_ext():
        sources = ["python/gumath/examples.c"]

        return Extension("gumath.examples",
                         include_dirs=add_include_dirs,
                         library_dirs=add_library_dirs,
                         depends=add_depends,
                         sources=sources,
                         libraries=add_libraries,
                         extra_compile_args=add_extra_compile_args,
                         extra_link_args=add_extra_link_args,
                         runtime_library_dirs=add_runtime_library_dirs)

    extensions = [gumath_ext(), functions_ext(), examples_ext()]
    if config_vars.get("HAVE_CUDA"):
        extensions += [cuda_ext()]
    return extensions