Skip to content

Commit

Permalink
Diagnose missing Cython-generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
soltanmm committed Jan 30, 2016
1 parent 01ba279 commit 097070f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/python/grpcio/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 097070f

Please sign in to comment.