Ejemplo n.º 1
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'
     ]
Ejemplo n.º 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']
Ejemplo n.º 3
0
    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'])
Ejemplo n.º 4
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')
Ejemplo n.º 5
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')
Ejemplo n.º 6
0
    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']
Ejemplo n.º 7
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
Ejemplo n.º 8
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(
Ejemplo n.º 9
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
Ejemplo n.º 10
0
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,
                             )]