Python distutils.errors.CCompilerError() Examples

The following are 8 code examples of distutils.errors.CCompilerError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module distutils.errors , or try the search function .
Example #1
Source File: setup.py    From dragonfly with MIT License 6 votes vote down vote up
def construct_build_ext(build_ext):
    # This class allows extension building to fail.
    # https://stackoverflow.com/questions/41778153/
    ext_errors = (CCompilerError, DistutilsExecError,
                  DistutilsPlatformError, DistutilsError, IOError)
    class WrappedBuildExt(build_ext):
        def run(self):
            try:
                build_ext.run(self)
            except (DistutilsPlatformError, CompilerNotFound) as x:
                raise BuildFailed(x)

        def build_extension(self, ext):
            try:
                build_ext.build_extension(self, ext)
            except ext_errors as x:
                raise BuildFailed(x)
    return WrappedBuildExt 
Example #2
Source File: setup.py    From aiochclient with MIT License 5 votes vote down vote up
def build_extension(self, ext):
        try:
            build_ext.build_extension(self, ext)
        except (CCompilerError, DistutilsExecError, DistutilsPlatformError, ValueError):
            raise BuildFailed() 
Example #3
Source File: setup.py    From rankeval with Mozilla Public License 2.0 5 votes vote down vote up
def _check_openmp_support(self):
        # Compile a test program to determine if compiler supports OpenMP.
        _mkpath(self.build_temp)
        with stdchannel_redirected(sys.stderr, os.devnull):
            with _tempfile.NamedTemporaryFile(mode='w',
                                              dir=self.build_temp,
                                              prefix='openmptest',
                                              suffix='.c') as srcfile:
                _log.info("checking if compiler supports OpenMP")
                srcfile.write("""
                #include <omp.h>
                int testfunc() {
                    int i;
                    #pragma omp parallel for
                    for (i = 0; i < 10; i ++)
                        ;
                    return omp_get_num_threads();
                }
                """)
                srcfile.flush()
                try:
                    objects = self.compiler.compile([srcfile.name],
                                                    extra_postargs=["-fopenmp"],
                                                    output_dir="/")
                except _CCompilerError:
                    _log.info("compiler does not support OpenMP")
                    use_openmp = False
                else:
                    _log.info("enabling OpenMP support")
                    use_openmp = True
                    for o in objects:
                        os.remove(o)
            return use_openmp 
Example #4
Source File: setup.py    From knitlib with GNU Lesser General Public License v3.0 5 votes vote down vote up
def build_extension(self, ext):
        try:
            build_ext.build_extension(self, ext)
        except (CCompilerError, CompileError, DistutilsExecError) as e:
            self._unavailable(e)
            self.extensions = []  # avoid copying missing files (it would fail). 
Example #5
Source File: build.py    From pendulum with MIT License 5 votes vote down vote up
def build_extension(self, ext):
        try:
            build_ext.build_extension(self, ext)
        except (CCompilerError, DistutilsExecError, DistutilsPlatformError, ValueError):
            print("************************************************************")
            print("Cannot compile C accelerator module, use pure python version")
            print("************************************************************") 
Example #6
Source File: setup.py    From aiokafka with Apache License 2.0 5 votes vote down vote up
def build_extension(self, ext):
        try:
            build_ext.build_extension(self, ext)
        except (CCompilerError, DistutilsExecError, DistutilsPlatformError, ValueError):
            raise BuildFailed() 
Example #7
Source File: jythoncompiler.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def refuse_compilation(self, *args, **kwargs):
        """Refuse compilation"""
        raise CCompilerError('Compiling extensions is not supported on Jython') 
Example #8
Source File: setup.py    From rpy2 with GNU General Public License v2.0 5 votes vote down vote up
def get_c_extension_status(libraries=['R'], include_dirs=None,
                           library_dirs=None):
    c_code = ('#include <Rinterface.h>\n\n'
              'int main(int argc, char **argv) { return 0; }')
    tmp_dir = tempfile.mkdtemp(prefix='tmp_pw_r_')
    bin_file = os.path.join(tmp_dir, 'test_pw_r')
    src_file = bin_file + '.c'
    with open(src_file, 'w') as fh:
        fh.write(c_code)

    compiler = new_compiler()
    customize_compiler(compiler)
    try:
        compiler.link_executable(
            compiler.compile([src_file], output_dir=tmp_dir,
                             include_dirs=include_dirs),
            bin_file,
            libraries=libraries,
            library_dirs=library_dirs)
    except CCompilerError as cce:
        status = COMPILATION_STATUS.COMPILE_ERROR
        print(cce)
    except DistutilsExecError as dee:
        status = COMPILATION_STATUS.NO_COMPILER
        print(dee)
    except DistutilsPlatformError as dpe:
        status = COMPILATION_STATUS.PLATFORM_ERROR
        print(dpe)
    else:
        status = COMPILATION_STATUS.OK
    shutil.rmtree(tmp_dir)
    return status