• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ccompiler.new_compiler函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中numpy.distutils.ccompiler.new_compiler函数的典型用法代码示例。如果您正苦于以下问题:Python new_compiler函数的具体用法?Python new_compiler怎么用?Python new_compiler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了new_compiler函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_compile1

 def test_compile1(self):
     # Compile source and link the first source
     c = ccompiler.new_compiler()
     previousDir = os.getcwd()
     try:
         # Change directory to not screw up directories
         os.chdir(self._dir1)
         c.compile([os.path.basename(self._src1)], output_dir=self._dir1)
         # Ensure that the object exists
         assert_(os.path.isfile(self._src1.replace('.c', '.o')) or
                 os.path.isfile(self._src1.replace('.c', '.obj')))
     finally:
         os.chdir(previousDir)
开发者ID:dyao-vu,项目名称:meta-core,代码行数:13,代码来源:test_system_info.py


示例2: _init_cxxcompiler

    def _init_cxxcompiler(self, compiler_type):
        cxxcompiler = new_compiler(compiler=compiler_type, verbose=self.verbose, dry_run=self.dry_run, force=self.force)
        if cxxcompiler is not None:
            cxxcompiler.customize(self.distribution, need_cxx=1)
            cxxcompiler.customize_cmd(self)
            self.cxxcompiler = cxxcompiler.cxx_compiler()
            try:
                get_cxx_tool_path(self.cxxcompiler)
            except DistutilsSetupError:
                self.cxxcompiler = None

            if self.cxxcompiler:
                self.scons_cxxcompiler = dist2sconscxx(self.cxxcompiler)
                self.scons_cxxcompiler_path = protect_path(get_cxx_tool_path(self.cxxcompiler))
开发者ID:illume,项目名称:numpy3k,代码行数:14,代码来源:scons.py


示例3: test_compile2

 def test_compile2(self):
     # Compile source and link the second source
     tsi = self.c_temp2
     c = ccompiler.new_compiler()
     extra_link_args = tsi.calc_extra_info()['extra_link_args']
     previousDir = os.getcwd()
     try:
         # Change directory to not screw up directories
         os.chdir(self._dir2)
         c.compile([os.path.basename(self._src2)], output_dir=self._dir2,
                   extra_postargs=extra_link_args)
         # Ensure that the object exists
         assert_(os.path.isfile(self._src2.replace('.c', '.o')))
     finally:
         os.chdir(previousDir)
开发者ID:dyao-vu,项目名称:meta-core,代码行数:15,代码来源:test_system_info.py


示例4: have_compiler

def have_compiler():
    """ Return True if there appears to be an executable compiler
    """
    compiler = ccompiler.new_compiler()
    try:
        cmd = compiler.compiler  # Unix compilers
    except AttributeError:
        try:
            compiler.initialize()  # MSVC is different
        except DistutilsError:
            return False
        cmd = [compiler.cc]
    try:
        Popen(cmd, stdout=PIPE, stderr=PIPE)
    except OSError:
        return False
    return True
开发者ID:dyao-vu,项目名称:meta-core,代码行数:17,代码来源:test_system_info.py


示例5: _init_ccompiler

 def _init_ccompiler(self, compiler_type):
     # XXX: The logic to bypass distutils is ... not so logic.
     if compiler_type == "msvc":
         self._bypass_distutils_cc = True
     try:
         distutils_compiler = new_compiler(
             compiler=compiler_type, verbose=self.verbose, dry_run=self.dry_run, force=self.force
         )
         distutils_compiler.customize(self.distribution)
         # This initialization seems necessary, sometimes, for find_executable to work...
         if hasattr(distutils_compiler, "initialize"):
             distutils_compiler.initialize()
         self.scons_compiler = dist2sconscc(distutils_compiler)
         self.scons_compiler_path = protect_path(get_tool_path(distutils_compiler))
     except DistutilsPlatformError, e:
         if not self._bypass_distutils_cc:
             raise e
         else:
             self.scons_compiler = compiler_type
开发者ID:illume,项目名称:numpy3k,代码行数:19,代码来源:scons.py


示例6: finalize_options

    def finalize_options(self):
        old_build_ext.finalize_options(self)
        if self.distribution.has_scons_scripts():
            self.sconscripts = self.distribution.get_scons_scripts()
            self.pre_hooks = self.distribution.get_scons_pre_hooks()
            self.post_hooks = self.distribution.get_scons_post_hooks()
            self.pkg_names = self.distribution.get_scons_parent_names()
        else:
            self.sconscripts = []
            self.pre_hooks = []
            self.post_hooks = []
            self.pkg_names = []

        # Try to get the same compiler than the ones used by distutils: this is
        # non trivial because distutils and scons have totally different
        # conventions on this one (distutils uses PATH from user's environment,
        # whereas scons uses standard locations). The way we do it is once we
        # got the c compiler used, we use numpy.distutils function to get the
        # full path, and add the path to the env['PATH'] variable in env
        # instance (this is done in numpy.distutils.scons module).

        # XXX: The logic to bypass distutils is ... not so logic.
        compiler_type = self.compiler
        if compiler_type == 'msvc':
            self._bypass_distutils_cc = True
        from numpy.distutils.ccompiler import new_compiler
        try:
            distutils_compiler = new_compiler(compiler=compiler_type,
                                      verbose=self.verbose,
                                      dry_run=self.dry_run,
                                      force=self.force)
            distutils_compiler.customize(self.distribution)
            # This initialization seems necessary, sometimes, for find_executable to work...
            if hasattr(distutils_compiler, 'initialize'):
                distutils_compiler.initialize()
            self.scons_compiler = dist2sconscc(distutils_compiler)
            self.scons_compiler_path = protect_path(get_tool_path(distutils_compiler))
        except DistutilsPlatformError, e:
            if not self._bypass_distutils_cc:
                raise e
            else:
                self.scons_compiler = compiler_type
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:42,代码来源:scons.py


示例7: have_compiler

def have_compiler():
    """ Return True if there appears to be an executable compiler
    """
    compiler = ccompiler.new_compiler()
    compiler.customize(None)
    try:
        cmd = compiler.compiler  # Unix compilers
    except AttributeError:
        try:
            if not compiler.initialized:
                compiler.initialize()  # MSVC is different
        except (DistutilsError, ValueError):
            return False
        cmd = [compiler.cc]
    try:
        p = Popen(cmd, stdout=PIPE, stderr=PIPE)
        p.stdout.close()
        p.stderr.close()
        p.wait()
    except OSError:
        return False
    return True
开发者ID:Juanlu001,项目名称:numpy,代码行数:22,代码来源:test_system_info.py


示例8: create_compiler_instance

def create_compiler_instance(dist):
    # build_ext is in charge of building C/C++ files.
    # We are using it and dist to parse config files, and command line
    # configurations.  There may be other ways to handle this, but I'm
    # worried I may miss one of the steps in distutils if I do it my self.
    #ext_builder = build_ext(dist)
    #ext_builder.finalize_options ()

    # For some reason the build_ext stuff wasn't picking up the compiler
    # setting, so we grab it manually from the distribution object instead.
    opts = dist.command_options.get('build_ext',None)
    compiler_name = ''
    if opts:
        comp = opts.get('compiler',('',''))
        compiler_name = comp[1]

    # Create a new compiler, customize it based on the build settings,
    # and return it.
    if not compiler_name:
        compiler_name = None
    #print compiler_name
    compiler = new_compiler(compiler=compiler_name)
    customize_compiler(compiler)
    return compiler
开发者ID:1641731459,项目名称:scipy,代码行数:24,代码来源:platform_info.py


示例9: run

    def run (self):
        fn = os.path.join(self.config_path, "Make.cfg")
        if os.path.isfile(fn) and os.path.isfile(self.config_h):
            print '*'*70
            print 'Files\n%s\n%s\n exist.' % (fn,self.config_h)
            print 'Skipping pygist configuration'\
                  ' (remove %s to force reconfiguration).' % fn
            print '*'*70
            return

        from numpy.distutils.log import set_verbosity
        from numpy.distutils.ccompiler import new_compiler
        save_verbosity = set_verbosity(-1)
        self.compiler = new_compiler(compiler=self.compiler,
                                     verbose=0)
        old_spawn = self.compiler.spawn
        self.compiler.spawn = self.spawn
        from distutils.sysconfig import customize_compiler
        customize_compiler(self.compiler)

        self.configfile = open(fn,'w')
        self.configfile.write('# Make.cfg from setup.py script ' + time.ctime() + '\n')
        if sys.platform != 'win32':
            self.configfile.write('#')
            for item in os.uname():
                self.configfile.write(' '+item)
            self.configfile.write('\n')

        self.config_toplevel()
        self.config_unix()
        self.config_x11()
        print 'wrote',fn
        self.configfile.close()

        set_verbosity(save_verbosity)
        self.compiler.spawn = old_spawn
开发者ID:mbentz80,项目名称:jzigbeercp,代码行数:36,代码来源:config_pygist.py


示例10: finalize_options

    def finalize_options(self):
        old_build_ext.finalize_options(self)
        if self.distribution.has_scons_scripts():
            self.sconscripts = self.distribution.get_scons_scripts()
            self.pre_hooks = self.distribution.get_scons_pre_hooks()
            self.post_hooks = self.distribution.get_scons_post_hooks()
            self.pkg_names = self.distribution.get_scons_parent_names()
        else:
            self.sconscripts = []
            self.pre_hooks = []
            self.post_hooks = []
            self.pkg_names = []

        # To avoid trouble, just don't do anything if no sconscripts are used.
        # This is  useful when for example f2py uses numpy.distutils, because
        # f2py does not pass compiler information to scons command, and the
        # compilation setup below can crash in some situation.
        if len(self.sconscripts) > 0:
            # Try to get the same compiler than the ones used by distutils: this is
            # non trivial because distutils and scons have totally different
            # conventions on this one (distutils uses PATH from user's environment,
            # whereas scons uses standard locations). The way we do it is once we
            # got the c compiler used, we use numpy.distutils function to get the
            # full path, and add the path to the env['PATH'] variable in env
            # instance (this is done in numpy.distutils.scons module).

            # XXX: The logic to bypass distutils is ... not so logic.
            compiler_type = self.compiler
            if compiler_type == 'msvc':
                self._bypass_distutils_cc = True
            from numpy.distutils.ccompiler import new_compiler
            try:
                distutils_compiler = new_compiler(compiler=compiler_type,
                                          verbose=self.verbose,
                                          dry_run=self.dry_run,
                                          force=self.force)
                distutils_compiler.customize(self.distribution)
                # This initialization seems necessary, sometimes, for find_executable to work...
                if hasattr(distutils_compiler, 'initialize'):
                    distutils_compiler.initialize()
                self.scons_compiler = dist2sconscc(distutils_compiler)
                self.scons_compiler_path = protect_path(get_tool_path(distutils_compiler))
            except DistutilsPlatformError, e:
                if not self._bypass_distutils_cc:
                    raise e
                else:
                    self.scons_compiler = compiler_type

            # We do the same for the fortran compiler ...
            fcompiler_type = self.fcompiler
            from numpy.distutils.fcompiler import new_fcompiler
            self.fcompiler = new_fcompiler(compiler = fcompiler_type,
                                           verbose = self.verbose,
                                           dry_run = self.dry_run,
                                           force = self.force)
            if self.fcompiler is not None:
                self.fcompiler.customize(self.distribution)

            # And the C++ compiler
            cxxcompiler = new_compiler(compiler = compiler_type,
                                       verbose = self.verbose,
                                       dry_run = self.dry_run,
                                       force = self.force)
            if cxxcompiler is not None:
                cxxcompiler.customize(self.distribution, need_cxx = 1)
                cxxcompiler.customize_cmd(self)
                self.cxxcompiler = cxxcompiler.cxx_compiler()
                try:
                    get_cxx_tool_path(self.cxxcompiler)
                except DistutilsSetupError:
                    self.cxxcompiler = None

            if self.package_list:
                self.package_list = parse_package_list(self.package_list)
开发者ID:The-Franklin-Institute,项目名称:ARIEL_Builder,代码行数:74,代码来源:scons.py


示例11: check_openmp_support

def check_openmp_support():
    """Check whether OpenMP test code can be compiled and run"""
    ccompiler = new_compiler()
    customize_compiler(ccompiler)

    if os.getenv('SKLEARN_NO_OPENMP'):
        # Build explicitly without OpenMP support
        return False

    start_dir = os.path.abspath('.')

    with tempfile.TemporaryDirectory() as tmp_dir:
        try:
            os.chdir(tmp_dir)

            # Write test program
            with open('test_openmp.c', 'w') as f:
                f.write(CCODE)

            os.mkdir('objects')

            # Compile, test program
            openmp_flags = get_openmp_flag(ccompiler)
            ccompiler.compile(['test_openmp.c'], output_dir='objects',
                              extra_postargs=openmp_flags)

            # Link test program
            extra_preargs = os.getenv('LDFLAGS', None)
            if extra_preargs is not None:
                extra_preargs = extra_preargs.split(" ")
            else:
                extra_preargs = []

            objects = glob.glob(
                os.path.join('objects', '*' + ccompiler.obj_extension))
            ccompiler.link_executable(objects, 'test_openmp',
                                      extra_preargs=extra_preargs,
                                      extra_postargs=openmp_flags)

            # Run test program
            output = subprocess.check_output('./test_openmp')
            output = output.decode(sys.stdout.encoding or 'utf-8').splitlines()

            # Check test program output
            if 'nthreads=' in output[0]:
                nthreads = int(output[0].strip().split('=')[1])
                openmp_supported = (len(output) == nthreads)
            else:
                openmp_supported = False

        except (CompileError, LinkError, subprocess.CalledProcessError):
            openmp_supported = False

        finally:
            os.chdir(start_dir)

    err_message = textwrap.dedent(
        """
                            ***

        It seems that scikit-learn cannot be built with OpenMP support.

        - Make sure you have followed the installation instructions:

            https://scikit-learn.org/dev/developers/advanced_installation.html

        - If your compiler supports OpenMP but the build still fails, please
          submit a bug report at:

            https://github.com/scikit-learn/scikit-learn/issues

        - If you want to build scikit-learn without OpenMP support, you can set
          the environment variable SKLEARN_NO_OPENMP and rerun the build
          command. Note however that some estimators will run in sequential
          mode and their `n_jobs` parameter will have no effect anymore.

                            ***
        """)

    if not openmp_supported:
        raise CompileError(err_message)

    return True
开发者ID:daniel-perry,项目名称:scikit-learn,代码行数:83,代码来源:openmp_helpers.py



注:本文中的numpy.distutils.ccompiler.new_compiler函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ccompiler.CCompiler类代码示例发布时间:2022-05-27
下一篇:
Python ctypeslib.ndpointer函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap