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


Python ccompiler.new_compiler方法代碼示例

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


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

示例1: have_compiler

# 需要導入模塊: from numpy.distutils import ccompiler [as 別名]
# 或者: from numpy.distutils.ccompiler import new_compiler [as 別名]
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:
        p = Popen(cmd, stdout=PIPE, stderr=PIPE)
        p.stdout.close()
        p.stderr.close()
        p.wait()
    except OSError:
        return False
    return True 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:22,代碼來源:test_system_info.py

示例2: have_compiler

# 需要導入模塊: from numpy.distutils import ccompiler [as 別名]
# 或者: from numpy.distutils.ccompiler import new_compiler [as 別名]
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:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:19,代碼來源:test_system_info.py

示例3: create_compiler_instance

# 需要導入模塊: from numpy.distutils import ccompiler [as 別名]
# 或者: from numpy.distutils.ccompiler import new_compiler [as 別名]
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:ktraunmueller,項目名稱:Computable,代碼行數:26,代碼來源:platform_info.py

示例4: have_compiler

# 需要導入模塊: from numpy.distutils import ccompiler [as 別名]
# 或者: from numpy.distutils.ccompiler import new_compiler [as 別名]
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:
            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:awslabs,項目名稱:mxnet-lambda,代碼行數:24,代碼來源:test_system_info.py

示例5: test_compile2

# 需要導入模塊: from numpy.distutils import ccompiler [as 別名]
# 或者: from numpy.distutils.ccompiler import new_compiler [as 別名]
def test_compile2(self):
        # Compile source and link the second source
        tsi = self.c_temp2
        c = ccompiler.new_compiler()
        c.customize(None)
        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:awslabs,項目名稱:mxnet-lambda,代碼行數:18,代碼來源:test_system_info.py

示例6: test_compile1

# 需要導入模塊: from numpy.distutils import ccompiler [as 別名]
# 或者: from numpy.distutils.ccompiler import new_compiler [as 別名]
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:ryfeus,項目名稱:lambda-packs,代碼行數:15,代碼來源:test_system_info.py

示例7: test_compile2

# 需要導入模塊: from numpy.distutils import ccompiler [as 別名]
# 或者: from numpy.distutils.ccompiler import new_compiler [as 別名]
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:ryfeus,項目名稱:lambda-packs,代碼行數:17,代碼來源:test_system_info.py

示例8: test_compile1

# 需要導入模塊: from numpy.distutils import ccompiler [as 別名]
# 或者: from numpy.distutils.ccompiler import new_compiler [as 別名]
def test_compile1(self):
        # Compile source and link the first source
        c = ccompiler.new_compiler()
        c.customize(None)
        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:awslabs,項目名稱:mxnet-lambda,代碼行數:16,代碼來源:test_system_info.py

示例9: compile_test_program

# 需要導入模塊: from numpy.distutils import ccompiler [as 別名]
# 或者: from numpy.distutils.ccompiler import new_compiler [as 別名]
def compile_test_program(code, extra_preargs=[], extra_postargs=[]):
    """Check that some C code can be compiled and run"""
    ccompiler = new_compiler()
    customize_compiler(ccompiler)

    # extra_(pre/post)args can be a callable to make it possible to get its
    # value from the compiler
    if callable(extra_preargs):
        extra_preargs = extra_preargs(ccompiler)
    if callable(extra_postargs):
        extra_postargs = extra_postargs(ccompiler)

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

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

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

            os.mkdir('objects')

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

            # Link test program
            objects = glob.glob(
                os.path.join('objects', '*' + ccompiler.obj_extension))
            ccompiler.link_executable(objects, 'test_program',
                                      extra_preargs=extra_preargs,
                                      extra_postargs=extra_postargs)

            # Run test program
            # will raise a CalledProcessError if return code was non-zero
            output = subprocess.check_output('./test_program')
            output = output.decode(sys.stdout.encoding or 'utf-8').splitlines()
        except Exception:
            raise
        finally:
            os.chdir(start_dir)

    return output 
開發者ID:alkaline-ml,項目名稱:pmdarima,代碼行數:47,代碼來源:pre_build_helpers.py


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