當前位置: 首頁>>代碼示例>>Python>>正文


Python unixccompiler.UnixCCompiler方法代碼示例

本文整理匯總了Python中distutils.unixccompiler.UnixCCompiler方法的典型用法代碼示例。如果您正苦於以下問題:Python unixccompiler.UnixCCompiler方法的具體用法?Python unixccompiler.UnixCCompiler怎麽用?Python unixccompiler.UnixCCompiler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在distutils.unixccompiler的用法示例。


在下文中一共展示了unixccompiler.UnixCCompiler方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _compile

# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
        # For sources other than CUDA C ones, just call the super class method.
        if os.path.splitext(src)[1] != '.cu':
            return unixccompiler.UnixCCompiler._compile(
                self, obj, src, ext, cc_args, extra_postargs, pp_opts)

        # For CUDA C source files, compile them with NVCC.
        _compiler_so = self.compiler_so
        try:
            nvcc_path = CUDA['nvcc']
            post_args = CUDA['post_args']
            # TODO? base_opts = build.get_compiler_base_options()
            self.set_executable('compiler_so', nvcc_path)

            return unixccompiler.UnixCCompiler._compile(
                self, obj, src, ext, cc_args, post_args, pp_opts)
        finally:
            self.compiler_so = _compiler_so 
開發者ID:benfred,項目名稱:implicit,代碼行數:20,代碼來源:cuda_setup.py

示例2: _compile_cu

# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def _compile_cu(self, sources, output_dir=None, macros=None,
                    include_dirs=None, debug=0, extra_preargs=None,
                    extra_postargs=None, depends=None):
        # Compile CUDA C files, mainly derived from UnixCCompiler._compile().
        macros, objects, extra_postargs, pp_opts, _build = \
            self._setup_compile(output_dir, macros, include_dirs, sources,
                                depends, extra_postargs)

        compiler_so = CUDA['nvcc']
        cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
        post_args = CUDA['post_args']

        for obj in objects:
            try:
                src, _ = _build[obj]
            except KeyError:
                continue
            try:
                self.spawn([compiler_so] + cc_args + [src, '-o', obj] + post_args)
            except errors.DistutilsExecError as e:
                raise errors.CompileError(str(e))

        return objects 
開發者ID:benfred,項目名稱:implicit,代碼行數:25,代碼來源:cuda_setup.py

示例3: get_ethtool_macro

# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def get_ethtool_macro():
        # see: https://github.com/giampaolo/psutil/issues/659
        from distutils.unixccompiler import UnixCCompiler
        from distutils.errors import CompileError

        with tempfile.NamedTemporaryFile(
                suffix='.c', delete=False, mode="wt") as f:
            f.write("#include <linux/ethtool.h>")

        output_dir = tempfile.mkdtemp()
        try:
            compiler = UnixCCompiler()
            # https://github.com/giampaolo/psutil/pull/1568
            if os.getenv('CC'):
                compiler.set_executable('compiler_so', os.getenv('CC'))
            with silenced_output('stderr'):
                with silenced_output('stdout'):
                    compiler.compile([f.name], output_dir=output_dir)
        except CompileError:
            return ("PSUTIL_ETHTOOL_MISSING_TYPES", 1)
        else:
            return None
        finally:
            os.remove(f.name)
            shutil.rmtree(output_dir) 
開發者ID:giampaolo,項目名稱:psutil,代碼行數:27,代碼來源:setup.py

示例4: _comiple_unix_hipcc

# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def _comiple_unix_hipcc(self,
                            obj, src, ext, cc_args, extra_postargs, pp_opts):
        # For CUDA C source files, compile them with HIPCC.
        _compiler_so = self.compiler_so
        try:
            rcom_path = build.get_hipcc_path()
            base_opts = build.get_compiler_base_options()
            self.set_executable('compiler_so', rcom_path)

            postargs = ['-O2', '-fPIC']
            print('HIPCC options:', postargs)

            return unixccompiler.UnixCCompiler._compile(
                self, obj, src, ext, base_opts + cc_args, postargs, pp_opts)
        finally:
            self.compiler_so = _compiler_so 
開發者ID:cupy,項目名稱:cupy,代碼行數:18,代碼來源:cupy_setup_build.py

示例5: link

# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def link(self, target_desc, objects, output_filename, *args):
        use_hipcc = False
        if use_hip:
            for i in objects:
                if 'cupy_thrust.o' in i:
                    use_hipcc = True
        if use_hipcc:
            _compiler_cxx = self.compiler_cxx
            try:
                rcom_path = build.get_hipcc_path()
                self.set_executable('compiler_cxx', rcom_path)

                return unixccompiler.UnixCCompiler.link(
                    self, target_desc, objects, output_filename, *args)
            finally:
                self.compiler_cxx = _compiler_cxx
        else:
            return unixccompiler.UnixCCompiler.link(
                self, target_desc, objects, output_filename, *args) 
開發者ID:cupy,項目名稱:cupy,代碼行數:21,代碼來源:cupy_setup_build.py

示例6: setUp

# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def setUp(self):
        self._backup_platform = sys.platform
        self._backup_get_config_var = sysconfig.get_config_var
        class CompilerWrapper(UnixCCompiler):
            def rpath_foo(self):
                return self.runtime_library_dir_option('/foo')
        self.cc = CompilerWrapper() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_unixccompiler.py

示例7: _compile

# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
        # For sources other than CUDA C ones, just call the super class method.
        if os.path.splitext(src)[1] != '.cu':
            return unixccompiler.UnixCCompiler._compile(
                self, obj, src, ext, cc_args, extra_postargs, pp_opts)

        if use_hip:
            return self._comiple_unix_hipcc(
                obj, src, ext, cc_args, extra_postargs, pp_opts)

        # For CUDA C source files, compile them with NVCC.
        _compiler_so = self.compiler_so
        try:
            nvcc_path = build.get_nvcc_path()
            base_opts = build.get_compiler_base_options()
            self.set_executable('compiler_so', nvcc_path)

            cuda_version = build.get_cuda_version()
            postargs = _nvcc_gencode_options(cuda_version) + [
                '-O2', '--compiler-options="-fPIC"', '--std=c++11']
            print('NVCC options:', postargs)

            return unixccompiler.UnixCCompiler._compile(
                self, obj, src, ext, base_opts + cc_args, postargs, pp_opts)
        finally:
            self.compiler_so = _compiler_so 
開發者ID:cupy,項目名稱:cupy,代碼行數:28,代碼來源:cupy_setup_build.py

示例8: _compile_cu

# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def _compile_cu(self, sources, output_dir=None, macros=None,
                    include_dirs=None, debug=0, extra_preargs=None,
                    extra_postargs=None, depends=None):
        # Compile CUDA C files, mainly derived from UnixCCompiler._compile().

        macros, objects, extra_postargs, pp_opts, _build = \
            self._setup_compile(output_dir, macros, include_dirs, sources,
                                depends, extra_postargs)

        compiler_so = build.get_nvcc_path()
        cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
        cuda_version = build.get_cuda_version()
        postargs = _nvcc_gencode_options(cuda_version) + ['-O2']
        postargs += ['-Xcompiler', '/MD']
        print('NVCC options:', postargs)

        for obj in objects:
            try:
                src, ext = _build[obj]
            except KeyError:
                continue
            try:
                self.spawn(compiler_so + cc_args + [src, '-o', obj] + postargs)
            except errors.DistutilsExecError as e:
                raise errors.CompileError(str(e))

        return objects 
開發者ID:cupy,項目名稱:cupy,代碼行數:29,代碼來源:cupy_setup_build.py

示例9: setUp

# 需要導入模塊: from distutils import unixccompiler [as 別名]
# 或者: from distutils.unixccompiler import UnixCCompiler [as 別名]
def setUp(self):
        self._backup_platform = sys.platform
        self._backup_get_config_var = sysconfig.get_config_var
        self._backup_get_config_vars = sysconfig.get_config_vars
        class CompilerWrapper(UnixCCompiler):
            def rpath_foo(self):
                return self.runtime_library_dir_option('/foo')
        self.cc = CompilerWrapper() 
開發者ID:pypa,項目名稱:setuptools,代碼行數:10,代碼來源:test_unixccompiler.py


注:本文中的distutils.unixccompiler.UnixCCompiler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。