Пример #1
0
def _have_c_compiler():
    from distutils.errors import DistutilsExecError, DistutilsModuleError, \
                             DistutilsPlatformError, CompileError
    from numpy.distutils import customized_ccompiler
    log.info('---------Detecting C compilers-------')
    try:
        c = customized_ccompiler()
        v = c.get_version()
        return True
    except (DistutilsModuleError, CompileError, AttributeError) as e:
        return False
Пример #2
0
 def test_compile1(self):
     # Compile source and link the first source
     c = customized_ccompiler()
     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)
Пример #3
0
 def test_compile1(self):
     # Compile source and link the first source
     c = customized_ccompiler()
     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)
Пример #4
0
 def test_compile2(self):
     # Compile source and link the second source
     tsi = self.c_temp2
     c = customized_ccompiler()
     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)
Пример #5
0
 def test_compile2(self):
     # Compile source and link the second source
     tsi = self.c_temp2
     c = customized_ccompiler()
     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)
def have_compiler():
    """Return True if there appears to be an executable compiler"""
    compiler = customized_ccompiler()
    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
Пример #7
0
def have_compiler():
    """ Return True if there appears to be an executable compiler
    """
    compiler = customized_ccompiler()
    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