From 27033c4f8d79ae60d7caf6313378da540e5411e6 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 9 Jul 2020 15:17:37 -0700 Subject: [PATCH 1/2] Update the hint for install Python header to depend on version --- src/python/grpcio/support.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/python/grpcio/support.py b/src/python/grpcio/support.py index 054f86445f5..7ee72da46b0 100644 --- a/src/python/grpcio/support.py +++ b/src/python/grpcio/support.py @@ -28,18 +28,20 @@ int main(int argc, char **argv) { return 0; } """ C_PYTHON_DEV_ERROR_MESSAGE = """ Could not find . This could mean the following: - * You're on Ubuntu and haven't run `apt-get install python-dev`. - * You're on RHEL/Fedora and haven't run `yum install python-devel` or - `dnf install python-devel` (make sure you also have redhat-rpm-config + * You're on Ubuntu and haven't run `apt-get install -dev`. + * You're on RHEL/Fedora and haven't run `yum install -devel` or + `dnf install -devel` (make sure you also have redhat-rpm-config installed) * You're on Mac OS X and the usual Python framework was somehow corrupted (check your environment variables or try re-installing?) * You're on Windows and your Python installation was somehow corrupted (check your environment variables or try re-installing?) """ +PYTHON_REPRESENTATION = 'python' if sys.version_info[0] == 2 else 'python3' C_CHECKS = { - C_PYTHON_DEV: C_PYTHON_DEV_ERROR_MESSAGE, + C_PYTHON_DEV: + C_PYTHON_DEV_ERROR_MESSAGE.replace('', PYTHON_REPRESENTATION), } From 8f3bd10c03659cd411fc5a5bf82b702adb5dc380 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 9 Jul 2020 15:34:06 -0700 Subject: [PATCH 2/2] Make sure >3 Python version triggers a failure --- src/python/grpcio/support.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/python/grpcio/support.py b/src/python/grpcio/support.py index 7ee72da46b0..217f3cb9ed5 100644 --- a/src/python/grpcio/support.py +++ b/src/python/grpcio/support.py @@ -37,7 +37,12 @@ Could not find . This could mean the following: * You're on Windows and your Python installation was somehow corrupted (check your environment variables or try re-installing?) """ -PYTHON_REPRESENTATION = 'python' if sys.version_info[0] == 2 else 'python3' +if sys.version_info[0] == 2: + PYTHON_REPRESENTATION = 'python' +elif sys.version_info[0] == 3: + PYTHON_REPRESENTATION = 'python3' +else: + raise NotImplementedError('Unsupported Python version: %s' % sys.version) C_CHECKS = { C_PYTHON_DEV: