Merge pull request #4976 from soltanmm/sigh-thon

Diagnose missing Cython-generated files
pull/4987/head
Masood Malekghassemi 9 years ago
commit 5db2fb7236
  1. 8
      src/python/grpcio/commands.py
  2. 21
      src/python/grpcio/support.py

@ -320,11 +320,11 @@ class BuildExt(build_ext.build_ext):
extension.extra_link_args += list(BuildExt.LINK_OPTIONS[compiler])
try:
build_ext.build_ext.build_extensions(self)
except KeyboardInterrupt:
raise
except Exception as error:
support.diagnose_build_ext_error(self, error, traceback.format_exc())
raise CommandError("Failed `build_ext` step.")
formatted_exception = traceback.format_exc()
support.diagnose_build_ext_error(self, error, formatted_exception)
raise CommandError(
"Failed `build_ext` step:\n{}".format(formatted_exception))
class Gather(setuptools.Command):

@ -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

Loading…
Cancel
Save