예제 #1
0
    def __init__(self, verbose=0, dry_run=0, force=0):

        CygwinCCompiler.__init__(self, verbose, dry_run, force)

        shared_option = "-shared"

        if is_cygwincc(self.cc):
            raise CCompilerError(
                'Cygwin gcc cannot be used with --compiler=mingw32')

        self.set_executables(compiler='%s -O -Wall' % self.cc,
                             compiler_so='%s -mdll -O -Wall' % self.cc,
                             compiler_cxx='%s -O -Wall' % self.cxx,
                             linker_exe='%s' % self.cc,
                             linker_so='%s %s' %
                             (self.linker_dll, shared_option))

        # Maybe we should also append -mthreads, but then the finished
        # dlls need another dll (mingwm10.dll see Mingw32 docs)
        # (-mthreads: Support thread-safe exception handling on `Mingw32')

        # no additional libraries needed
        self.dll_libraries = []

        # Include the appropriate MSVC runtime library if Python was built
        # with MSVC 7.0 or later.
        self.dll_libraries = get_msvcr()
예제 #2
0
    def run(self):
        build_dir = self.build_temp
        source_dir = path.dirname(path.abspath(__file__))
        install_dir = path.join(source_dir, 'dist')

        cmake_opts = [
            '-DCMAKE_INSTALL_PREFIX={}'.format(install_dir),
            '-DCMAKE_INSTALL_LIBDIR=lib',
            '-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE', '-DHUNTER_ENABLED=OFF',
            '-DETHASH_BUILD_TESTS=OFF', '-DETHASH_INSTALL_CMAKE_CONFIG=OFF'
        ]

        generator = os.environ.get('GENERATOR')
        if generator:
            cmake_opts.append('-G{}'.format(generator))

        if not self.skip_cmake_build and not os.environ.get(
                'ETHASH_PYTHON_SKIP_BUILD'):
            cmake_cmd = shutil.which('cmake')
            if not cmake_cmd:
                raise CCompilerError(
                    "cmake tool not found but required to build this package")

            r = subprocess.call([cmake_cmd, source_dir] + cmake_opts,
                                cwd=build_dir)
            if r != 0:
                raise CCompilerError(
                    "cmake configuration failed with exit status {}".format(r))
            r = subprocess.call([
                cmake_cmd, '--build', build_dir, '--target', 'install',
                '--config', 'Release'
            ])
            if r != 0:
                raise CCompilerError(
                    "cmake build failed with exit status {}".format(r))

        self.library_dirs.append(path.join(install_dir, 'lib'))

        super(build_ext, self).run()
예제 #3
0
    def __init__(self, verbose=0, dry_run=0, force=0):

        CygwinCCompiler.__init__ (self, verbose, dry_run, force)

        # ld_version >= "2.13" support -shared so use it instead of
        # -mdll -static
        if self.ld_version >= "2.13":
            shared_option = "-shared"
        else:
            shared_option = "-mdll -static"

        # A real mingw32 doesn't need to specify a different entry point,
        # but cygwin 2.91.57 in no-cygwin-mode needs it.
        if self.gcc_version <= "2.91.57":
            entry_point = '--entry _DllMain@12'
        else:
            entry_point = ''

        if is_cygwingcc():
            raise CCompilerError(
                'Cygwin gcc cannot be used with --compiler=mingw32')

        if sys.maxsize == 2**31 - 1:
            ms_win=' -DMS_WIN32'
        else:
            ms_win=' -DMS_WIN64'
        self.set_executables(compiler='gcc -O -Wall'+ms_win,
                             compiler_so='gcc -mdll -O -Wall'+ms_win,
                             compiler_cxx='g++ -O -Wall'+ms_win,
                             linker_exe='gcc',
                             linker_so='%s %s %s'
                                        % (self.linker_dll, shared_option,
                                           entry_point))
        # Maybe we should also append -mthreads, but then the finished
        # dlls need another dll (mingwm10.dll see Mingw32 docs)
        # (-mthreads: Support thread-safe exception handling on `Mingw32')

        # no additional libraries needed
        self.dll_libraries=[]

        # Include the appropriate MSVC runtime library if Python was built
        # with MSVC 7.0 or later.
        self.dll_libraries = get_msvcr()
예제 #4
0
 def __init__(self, verbose=0, dry_run=0, force=0):
     CygwinCCompiler.__init__(self, verbose, dry_run, force)
     if self.ld_version >= '2.13':
         shared_option = '-shared'
     else:
         shared_option = '-mdll -static'
     if self.gcc_version <= '2.91.57':
         entry_point = '--entry _DllMain@12'
     else:
         entry_point = ''
     if is_cygwingcc():
         raise CCompilerError(
             'Cygwin gcc cannot be used with --compiler=mingw32')
     self.set_executables(compiler='gcc -O -Wall',
                          compiler_so='gcc -mdll -O -Wall',
                          compiler_cxx='g++ -O -Wall',
                          linker_exe='gcc',
                          linker_so='%s %s %s' %
                          (self.linker_dll, shared_option, entry_point))
     self.dll_libraries = []
     self.dll_libraries = get_msvcr()
예제 #5
0
    def __init__(self, verbose=0, dry_run=0, force=0):

        CygwinCCompiler.__init__(self, verbose, dry_run, force)

        if is_cygwingcc():
            raise CCompilerError(
                'Cygwin gcc cannot be used with --compiler=mingw32')

        # Configure 64 bit options.
        if "AMD64" in sys.version:
            self.set_executables(
                compiler=
                'gcc -O2 -Wall -DMS_WIN64 -fno-strict-aliasing -fwrapv',
                compiler_so=
                'gcc -mdll -O2 -Wall -DMS_WIN64 -fno-strict-aliasing -fwrapv',
                compiler_cxx='g++ -O2 -Wall -fno-strict-aliasing -fwrapv',
                linker_exe='gcc',
                linker_so='gcc -shared')
        else:
            self.set_executables(
                compiler='gcc -O2 -Wall -fno-strict-aliasing -fwrapv',
                compiler_so='gcc -mdll -O2 -Wall -fno-strict-aliasing -fwrapv',
                compiler_cxx='g++ -O2 -Wall -fno-strict-aliasing -fwrapv',
                linker_exe='gcc',
                linker_so='gcc -shared')

        # Maybe we should also append -mthreads, but then the finished
        # dlls need another dll (mingwm10.dll see Mingw32 docs)
        # (-mthreads: Support thread-safe exception handling on `Mingw32')

        # no additional libraries needed
        self.dll_libraries = []

        # Include the appropriate MSVC runtime library if Python was built
        # with MSVC 7.0 or later.
        self.dll_libraries = []
예제 #6
0
 def refuse_compilation(self, *args, **kwargs):
     """Refuse compilation"""
     raise CCompilerError('Compiling extensions is not supported on Jython')
예제 #7
0
    def finalize_options(self):
        build_clib.finalize_options(self)

        compiler = new_compiler(compiler=self.compiler, verbose=self.verbose)
        customize_compiler(compiler)

        disabled_libraries = []

        # Section for custom limits imposed on the SIMD instruction
        # levels based on the installed compiler
        plat_compiler = platform.python_compiler()
        if plat_compiler.lower().startswith('gcc'):
            log.info('gcc detected')
            # Check the installed gcc version, as versions older than
            # 7.0 claim to support avx512 but are missing some
            # intrinsics that FastNoiseSIMD calls.
            output = sub.check_output('gcc --version', shell=True)
            gcc_version = tuple([
                int(x)
                for x in re.findall(b'\d+(?:\.\d+)+', output)[0].split(b'.')
            ])
            if gcc_version < (7, 2):  # Disable AVX512
                log.info('Disabled avx512; not supported with gcc < 7.2.')
                disabled_libraries.append('avx512')
            if gcc_version < (4, 7):  # Disable AVX2
                log.info('Disabled avx2; not supported with gcc < 4.7.')
                disabled_libraries.append('avx2')
        elif plat_compiler.lower().startswith('msc'):
            # No versions of Windows Python support AVX512 yet,
            # it is supported in MSVC2017 only.
            #                 MSVC++ 14.1 _MSC_VER == 1911 (Visual Studio 2017)
            #                 MSVC++ 14.1 _MSC_VER == 1910 (Visual Studio 2017)
            # Python 3.5/3.6: MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
            # Python 3.4:     MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
            # Python 2.7:     MSVC++ 9.0  _MSC_VER == 1500 (Visual Studio 2008)
            # Here we just assume the user has the platform compiler
            msc_version = int(
                re.findall('v\.\d+', plat_compiler)[0].lstrip('v.'))
            if msc_version < 1910:
                disabled_libraries.append('avx512')
            if msc_version < 1900:
                disabled_libraries.append('avx2')
        # End of SIMD limits

        for name, lib in self.distribution.libraries:
            val = getattr(self, 'with_' + name)
            if val not in ('auto', 'yes', 'no'):
                raise DistutilsOptionError('with_%s flag must be auto, yes, '
                                           'or no, not "%s".' % (name, val))

            if val == 'no':
                disabled_libraries.append(name)
                continue

            if not self.compiler_has_flags(compiler, name, lib['cflags']):
                if val == 'yes':
                    # Explicitly required but not available.
                    raise CCompilerError('%s is not supported by your '
                                         'compiler.' % (name, ))
                disabled_libraries.append(name)

        use_fma = False
        if (self.with_fma != 'no' and ('avx512' not in disabled_libraries
                                       or 'avx2' not in disabled_libraries)):
            if fma_flags is None:
                # No flags required.
                use_fma = True
            elif self.compiler_has_flags(compiler, 'fma', fma_flags):
                use_fma = True
                avx512['cflags'] += fma_flags
                avx2['cflags'] += fma_flags
            elif self.with_fma == 'yes':
                # Explicitly required but not available.
                raise CCompilerError('FMA is not supported by your compiler.')

        self.distribution.libraries = [
            lib for lib in self.distribution.libraries
            if lib[0] not in disabled_libraries
        ]

        with open(SIMD_NOISE_SOURCES + '/x86_flags.h', 'wb') as fh:
            fh.write(b'// This file is generated by setup.py, '
                     b'do not edit it by hand\n')
            for name, lib in self.distribution.libraries:
                fh.write(b'#define FN_COMPILE_%b\n' %
                         (name.upper().encode('ascii', )))
            if use_fma:
                fh.write(b'#define FN_USE_FMA\n')