diff options
author | Masood Malekghassemi <soltanmm@users.noreply.github.com> | 2016-01-30 14:26:06 -0800 |
---|---|---|
committer | Masood Malekghassemi <soltanmm@users.noreply.github.com> | 2016-01-30 14:26:49 -0800 |
commit | 097070fe207728156205c04c2e7506776af18090 (patch) | |
tree | 763f33a67a02a383f7f6ecf87b39d4fda9809e43 /src/python/grpcio | |
parent | 01ba279fdddb28096893a4e09a62b915cdbca6be (diff) |
Diagnose missing Cython-generated files
Diffstat (limited to 'src/python/grpcio')
-rw-r--r-- | src/python/grpcio/support.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/python/grpcio/support.py b/src/python/grpcio/support.py index 96d9cbf4f3..33244eb388 100644 --- a/src/python/grpcio/support.py +++ b/src/python/grpcio/support.py @@ -77,10 +77,27 @@ def _expect_compile(compiler, source_string, error_message): .format(error_message)) def diagnose_compile_error(build_ext, error): - """Attempt to run a few test files through the compiler to see if we can - diagnose the reason for the compile failure.""" + """Attempt to diagnose an error during compilation.""" for c_check, message in C_CHECKS.items(): _expect_compile(build_ext.compiler, c_check, message) + python_sources = [ + source for source in build_ext.get_source_files() + if source.startswith('./src/python') and source.endswith('c') + ] + for source in python_sources: + if not os.path.isfile(source): + raise commands.CommandError( + ("Diagnostics found a missing Python extension source file:\n{}\n\n" + "This is usually because the Cython sources haven't been transpiled " + "into C yet and you're building from source.\n" + "Try setting the environment variable " + "`GRPC_PYTHON_BUILD_WITH_CYTHON=1` when invoking `setup.py` or " + "when using `pip`, e.g.:\n\n" + "pip install -rrequirements.txt\n" + "GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .") + .format(source) + ) + _ERROR_DIAGNOSES = { errors.CompileError: diagnose_compile_error |