Diagnose missing Cython-generated files

pull/4976/head
Masood Malekghassemi 9 years ago
parent 01ba279fdd
commit 097070fe20
  1. 21
      src/python/grpcio/support.py

@ -77,10 +77,27 @@ def _expect_compile(compiler, source_string, error_message):
.format(error_message)) .format(error_message))
def diagnose_compile_error(build_ext, error): def diagnose_compile_error(build_ext, error):
"""Attempt to run a few test files through the compiler to see if we can """Attempt to diagnose an error during compilation."""
diagnose the reason for the compile failure."""
for c_check, message in C_CHECKS.items(): for c_check, message in C_CHECKS.items():
_expect_compile(build_ext.compiler, c_check, message) _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 = { _ERROR_DIAGNOSES = {
errors.CompileError: diagnose_compile_error errors.CompileError: diagnose_compile_error

Loading…
Cancel
Save