Esempio n. 1
0
    def build_extensions(self):
        # Numpy bug: if an extension has a library only consisting of f77
        # files, the extension language will always be f77 and no f90
        # compiler will be initialized
        need_f90_compiler = self._f90_compiler is None and \
            any(any(f90_ext_match(s) for s in _.sources)
                for _ in self.extensions)
        if need_f90_compiler:
            self._f90_compiler = new_fcompiler(compiler=self.fcompiler,
                                               verbose=self.verbose,
                                               dry_run=self.dry_run,
                                               force=self.force,
                                               requiref90=True,
                                               c_compiler=self.compiler)
            fcompiler = self._f90_compiler
            if fcompiler:
                fcompiler.customize(self.distribution)
            if fcompiler and fcompiler.get_version():
                fcompiler.customize_cmd(self)
                fcompiler.show_customization()
            else:
                ctype = fcompiler.compiler_type if fcompiler \
                    else self.fcompiler
                self.warn('f90_compiler=%s is not available.' % ctype)

        for fc in self._f77_compiler, self._f90_compiler:
            if isinstance(fc,
                          numpy.distutils.fcompiler.gnu.Gnu95FCompiler):
                flags = F77_COMPILE_ARGS_GFORTRAN + F77_COMPILE_OPT_GFORTRAN
                if self.debug:
                    flags += F77_COMPILE_DEBUG_GFORTRAN
                if F77_OPENMP:
                    flags += ['-openmp']
                fc.executables['compiler_f77'] += flags
                flags = F90_COMPILE_ARGS_GFORTRAN + F90_COMPILE_OPT_GFORTRAN
                if self.debug:
                    flags += F90_COMPILE_DEBUG_GFORTRAN
                if F90_OPENMP:
                    flags += ['-openmp']
                fc.executables['compiler_f90'] += flags
                fc.libraries += [LIBRARY_OPENMP_GFORTRAN]
            elif isinstance(fc,
                            numpy.distutils.fcompiler.intel.IntelFCompiler):
                flags = F77_COMPILE_ARGS_IFORT + F77_COMPILE_OPT_IFORT
                if self.debug:
                    flags += F77_COMPILE_DEBUG_IFORT
                if F77_OPENMP:
                    flags += ['-openmp']
                fc.executables['compiler_f77'] += flags
                flags = F90_COMPILE_ARGS_IFORT + F90_COMPILE_OPT_IFORT
                if self.debug:
                    flags += F90_COMPILE_DEBUG_IFORT
                if F90_OPENMP:
                    flags += ['-openmp']
                fc.executables['compiler_f90'] += flags
                fc.libraries += [LIBRARY_OPENMP_IFORT]
            elif fc is not None:
                raise RuntimeError(
                    "Unhandled compiler: '{}'.".format(fcompiler))
        build_ext.build_extensions(self)
Esempio n. 2
0
    def build_extensions(self):

        plat = platform.system()
        plat_ver = platform.release()

        print("OS: %s" % (plat))
        print("OS version: %s" % (plat_ver))

        if plat == 'Windows':

            print("On windows we don't perform checks")
            build_ext.build_extensions(self)

        elif plat in ['Linux', 'Darwin']:
            if (check_unix_compiler(
                    plat, plat_ver, self.compiler, self.extensions,
                    self.compiler.compiler_cxx[0]) and check_unix_compiler(
                        plat, plat_ver, self.compiler, self.extensions,
                        self.compiler.compiler_so[0])):

                for e in self.extensions:
                    print("  extra_args=%s" % (e.extra_compile_args))

                build_ext.build_extensions(self)
            else:
                print(
                    "Cannot build phoebe2. Please check the dependencies and try again."
                )
                sys.exit(1)
        else:
            print(
                "Unknown architecture, so no pre-checks done. Please report in the case of build failure."
            )
            sys.exit(1)
Esempio n. 3
0
    def build_extensions(self):
        # Numpy bug: if an extension has a library only consisting of f77
        # files, the extension language will always be f77 and no f90
        # compiler will be initialized
        need_f90_compiler = self._f90_compiler is None and \
            any(any(f90_ext_match(s) for s in _.sources)
                for _ in self.extensions)
        if need_f90_compiler:
            self._f90_compiler = new_fcompiler(compiler=self.fcompiler,
                                               verbose=self.verbose,
                                               dry_run=self.dry_run,
                                               force=self.force,
                                               requiref90=True,
                                               c_compiler=self.compiler)
            fcompiler = self._f90_compiler
            if fcompiler:
                fcompiler.customize(self.distribution)
            if fcompiler and fcompiler.get_version():
                fcompiler.customize_cmd(self)
                fcompiler.show_customization()
            else:
                ctype = fcompiler.compiler_type if fcompiler \
                    else self.fcompiler
                self.warn('f90_compiler=%s is not available.' % ctype)

        for fc in self._f77_compiler, self._f90_compiler:
            if isinstance(fc, numpy.distutils.fcompiler.gnu.Gnu95FCompiler):
                flags = F77_COMPILE_ARGS_GFORTRAN + F77_COMPILE_OPT_GFORTRAN
                if self.debug:
                    flags += F77_COMPILE_DEBUG_GFORTRAN
                if F77_OPENMP:
                    flags += ['-openmp']
                fc.executables['compiler_f77'] += flags
                flags = F90_COMPILE_ARGS_GFORTRAN + F90_COMPILE_OPT_GFORTRAN
                if self.debug:
                    flags += F90_COMPILE_DEBUG_GFORTRAN
                if F90_OPENMP:
                    flags += ['-openmp']
                fc.executables['compiler_f90'] += flags
                fc.libraries += [LIBRARY_OPENMP_GFORTRAN]
            elif isinstance(fc,
                            numpy.distutils.fcompiler.intel.IntelFCompiler):
                flags = F77_COMPILE_ARGS_IFORT + F77_COMPILE_OPT_IFORT
                if self.debug:
                    flags += F77_COMPILE_DEBUG_IFORT
                if F77_OPENMP:
                    flags += ['-qopenmp']
                fc.executables['compiler_f77'] += flags
                flags = F90_COMPILE_ARGS_IFORT + F90_COMPILE_OPT_IFORT
                if self.debug:
                    flags += F90_COMPILE_DEBUG_IFORT
                if F90_OPENMP:
                    flags += ['-qopenmp']
                fc.executables['compiler_f90'] += flags
                fc.libraries += [LIBRARY_OPENMP_IFORT]
            elif fc is not None:
                raise RuntimeError(
                    "Unhandled compiler: '{}'.".format(fcompiler))
        build_ext.build_extensions(self)
Esempio n. 4
0
    def build_extensions(self):

        if not os.getenv('MREX_NO_OPENMP'):
            openmp_flag = get_openmp_flag(self.compiler)

            for e in self.extensions:
                e.extra_compile_args += openmp_flag
                e.extra_link_args += openmp_flag

        build_ext.build_extensions(self)
Esempio n. 5
0
    def build_extensions(self):
        """ Hook into extension building to check compiler flags """

        if self.can_compile_link():

            for ext in self.extensions:
                ext.extra_compile_args += compile_flags
                ext.extra_link_args += link_flags

        build_ext.build_extensions(self)
Esempio n. 6
0
        def build_extensions(self):
            """ Hook into extension building to check compiler flags """

            if self.can_compile_link():

                for ext in self.extensions:
                    ext.extra_compile_args += compile_flags
                    ext.extra_link_args += link_flags

            build_ext.build_extensions(self)
Esempio n. 7
0
    def build_extensions(self):
        from sklearn._build_utils.openmp_helpers import get_openmp_flag

        if not os.getenv('SKLEARN_NO_OPENMP'):
            openmp_flag = get_openmp_flag(self.compiler)

            for e in self.extensions:
                e.extra_compile_args += openmp_flag
                e.extra_link_args += openmp_flag

        build_ext.build_extensions(self)
Esempio n. 8
0
        def build_extensions(self):  # noqa
            from oblique_forests._build_utils.openmp_helpers import get_openmp_flag

            if not os.getenv('SKLEARN_NO_OPENMP'):
                openmp_flag = get_openmp_flag(self.compiler)

                for e in self.extensions:
                    e.extra_compile_args += openmp_flag
                    e.extra_link_args += openmp_flag

            build_ext.build_extensions(self)
Esempio n. 9
0
        def build_extensions(self):
            from sklearn._build_utils.openmp_helpers import get_openmp_flag

            if sklearn._OPENMP_SUPPORTED:
                openmp_flag = get_openmp_flag(self.compiler)

                for e in self.extensions:
                    e.extra_compile_args += openmp_flag
                    e.extra_link_args += openmp_flag

            build_ext.build_extensions(self)
Esempio n. 10
0
        def build_extensions(self):
            from sktime._build_utils.openmp_helpers import get_openmp_flag

            if not os.getenv("SKTIME_NO_OPENMP"):
                openmp_flag = get_openmp_flag(self.compiler)

                for e in self.extensions:
                    e.extra_compile_args += openmp_flag
                    e.extra_link_args += openmp_flag

            build_ext.build_extensions(self)
Esempio n. 11
0
 def build_extensions(self):
     c = self.compiler.compiler[0]
     print("Building extension with {}".format(c))
     if 'gcc' in c:
         for e in self.extensions:
             e.extra_compile_args.append('-fopenmp')
             e.libraries.append('gomp')
     elif 'intel' in c:
         for e in self.extensions:
             e.extra_compile_args.append('-qopenmp')
     build_ext.build_extensions(self)
Esempio n. 12
0
    def build_extensions(self):
        if hasattr(self.compiler, 'compiler'):
            compiler = self.compiler.compiler[0]
        else:
            compiler = self.compiler.__class__.__name__

        openmp_flag = get_openmp_flag(compiler)

        for e in self.extensions:
            e.extra_compile_args += openmp_flag
            e.extra_link_args += openmp_flag

        build_ext.build_extensions(self)
Esempio n. 13
0
    def build_extensions(self):
        if hasattr(self.compiler, 'compiler'):
            compiler = self.compiler.compiler[0]
        else:
            compiler = self.compiler.__class__.__name__

        openmp_flag = get_openmp_flag(compiler)

        for e in self.extensions:
            e.extra_compile_args += openmp_flag
            e.extra_link_args += openmp_flag

        build_ext.build_extensions(self)
Esempio n. 14
0
    def build_extensions(self):
        if (check_compiler(self.compiler, self.extensions,
                           self.compiler.compiler_cxx[0])
                and check_compiler(self.compiler, self.extensions,
                                   self.compiler.compiler_so[0])):

            for e in self.extensions:
                print("  extra_args=%s" % (e.extra_compile_args))

            build_ext.build_extensions(self)
        else:
            print(
                "Cannot build phoebe2. Please check the dependencies and try again."
            )
            sys.exit(1)
Esempio n. 15
0
        def build_extensions(self):
            """ Hook into extension building to check compiler flags """

            compile_flags = link_flags = []
            if self.compiler.compiler_type == 'msvc':
                compile_flags += ['/openmp']
                link_flags += ['/openmp']
            else:
                compile_flags += ['-fopenmp']
                link_flags += ['-fopenmp']

            if self.can_compile_link(compile_flags, link_flags):
                for ext in self.extensions:
                    ext.extra_compile_args += compile_flags
                    ext.extra_link_args += link_flags

            build_ext.build_extensions(self)
Esempio n. 16
0
        def build_extensions(self):
            # setup OpenMP support
            from setup_util import detect_openmp
            openmp_enabled, additional_libs = detect_openmp(self.compiler)
            if openmp_enabled:
                warnings.warn('enabled openmp')
                if sys.platform == 'darwin':
                    omp_compiler_args = ['-fopenmp=libiomp5']
                else:
                    omp_compiler_args = ['-fopenmp']
                omp_libraries = ['-l%s' % l for l in additional_libs]
                omp_defines = [('USE_OPENMP', None)]
                for ext in self.extensions:
                    ext.extra_compile_args += omp_compiler_args
                    ext.extra_link_args += omp_libraries
                    ext.define_macros += omp_defines

            build_ext.build_extensions(self)
Esempio n. 17
0
            def build_extensions(self, *args, **kwargs):
                c = self.compiler.compiler_type
                for e in self.extensions:
                    if c in copt:
                        e.extra_compile_args.extend(copt[c])
                    if c in lopt:
                        e.extra_link_args.extend(lopt[c])
                    e.include_dirs.append(distutils.sysconfig.get_python_inc())

                return build_ext.build_extensions(self, *args, **kwargs)
Esempio n. 18
0
 def build_extensions(self, *args, **kwargs):
     c = self.compiler.compiler_type
     for e in self.extensions:
         if c in copt:
             e.extra_compile_args.extend(copt[c])
         if c in lopt:
             e.extra_link_args.extend(lopt[c])
         e.include_dirs.append(distutils.sysconfig.get_python_inc())
     
     return build_ext.build_extensions(self, *args, **kwargs)
Esempio n. 19
0
    def build_extensions(self):
        """ Hook into extension building to set compiler flags """

        compile_flags = list()
        link_flags = list()

        # check which compiler is being used
        if self.compiler.compiler_type == "msvc":
            # '-fopenmp' is called '/openmp' in msvc
            compile_flags += ['/openmp']
        else:
            compile_flags += ['-fopenmp']
            link_flags += ['-fopenmp']

        if self.can_compile_link(compile_flags, link_flags):
            for ext in self.extensions:
                ext.extra_compile_args += compile_flags
                ext.extra_link_args += link_flags

        build_ext.build_extensions(self)
Esempio n. 20
0
    def build_extensions(self):
        """Build extensions.

        Since there is no direct way to achieve this from setup file, this method resolves to
        dirty trick of modifying state of isingcpu extension.
        Basically we check what Fortran compiler is in use and then construct extra compiler
        args and list of additional libraries to link.
        """
        fcompiler = self.fcompiler or 'gnu95'
        customize_compiler_for_nvcc(self.compiler)

        try:
            cuda_home = find_cuda_home()
            self.compiler.has_nvcc = True
            for ext in self.extensions:
                ext.include_dirs += [os.path.join(cuda_home, 'include')]
        except ValueError:
            self.compiler.has_nvcc = False

        if not self.usecuda:
            self._remove_gpu_search_ext(self.extensions)
        else:
            cuda_ver = get_cuda_version()
            for ext in self.extensions:
                if 'isinggpu' in ext.name:
                    ext.extra_f90_compile_args.append('-Mcuda=nordc,cuda'+cuda_ver)
                ext.extra_link_args.append('-Mcuda=cuda'+cuda_ver)
        with open(CONFIG_MAP[fcompiler], 'rt') as cfg_file:
            cfg = json.load(cfg_file)

        if '--debug' in sys.argv:
            base_args = cfg['fortran_compile_args']['debug']
        else:
            base_args = cfg['fortran_compile_args']['optimal']

        cpu_search_ext = [ext for ext in self.extensions if 'isingcpu' in ext.name][0]
        cpu_search_ext.extra_f90_compile_args = cfg['fortran_compile_args']['common'] + base_args
        cpu_search_ext.libraries = cfg['libraries']
#        cpu_search_ext.library_dirs += [find_cuda_lib_dir()]
        cpu_search_ext.extra_link_args += cfg.get('link_args', [])
        build_ext.build_extensions(self)
Esempio n. 21
0
    def build_extensions(self):
        ccompiler = self.compiler.compiler_type
        fcompiler = self._f77_compiler.compiler_type

        # add the compiler dependent options to each extension
        for extension in self.extensions:
            try:
                modification = ccompiler_dependent_options[ccompiler]
                for key, val in modification.items():
                    getattr(extension, key).extend(val)
            except (KeyError, AttributeError):
                pass

            try:
                modification = fcompiler_dependent_options[fcompiler]
                for key, val in modification.items():
                    getattr(extension, key).extend(val)
            except (KeyError, AttributeError):
                pass

        build_ext.build_extensions(self)
Esempio n. 22
0
    def build_extensions(self):
        ccompiler = self.compiler.compiler_type
        fcompiler = self._f77_compiler.compiler_type

        # add the compiler dependent options to each extension
        for extension in self.extensions:
            try:
                modification = ccompiler_dependent_options[ccompiler]
                for key, val in modification.items():
                    getattr(extension, key).extend(val)
            except (KeyError, AttributeError):
                pass

            try:
                modification = fcompiler_dependent_options[fcompiler]
                for key, val in modification.items():
                    getattr(extension, key).extend(val)
            except (KeyError, AttributeError):
                pass

        build_ext.build_extensions(self)
Esempio n. 23
0
 def build_extensions(self):
     build_ext.build_extensions(self)
Esempio n. 24
0
 def build_extensions(self):
     self.check_cython_extensions(self.extensions)
     numpy_build_ext.build_extensions(self)