aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/distrib/python
diff options
context:
space:
mode:
authorGravatar Masood Malekghassemi <atash@google.com>2016-05-06 12:58:30 -0700
committerGravatar Masood Malekghassemi <atash@google.com>2016-05-07 13:01:14 -0700
commitb4e82f7897c8a840249f39f17bc9afb986206588 (patch)
tree0ad9a123f3aff26c6e27430102ca48a66bbb0e94 /tools/distrib/python
parent8c33c7442c79682d2e545820f5653cabf25fd07e (diff)
Fix windows linkage in Python grpcio-tools
Diffstat (limited to 'tools/distrib/python')
-rw-r--r--tools/distrib/python/grpcio_tools/README.rst4
-rw-r--r--tools/distrib/python/grpcio_tools/setup.py14
2 files changed, 16 insertions, 2 deletions
diff --git a/tools/distrib/python/grpcio_tools/README.rst b/tools/distrib/python/grpcio_tools/README.rst
index 3be564ef5b..10d2fe8c30 100644
--- a/tools/distrib/python/grpcio_tools/README.rst
+++ b/tools/distrib/python/grpcio_tools/README.rst
@@ -46,7 +46,9 @@ From Source
~~~~~~~~~~~
Building from source requires that you have the Python headers (usually a
-package named :code:`python-dev`) and Cython installed.
+package named :code:`python-dev`) and Cython installed. It further requires a
+GCC-like compiler to go smoothly; you can probably get it to work without
+GCC-like stuff, but you may end up having a bad time.
::
diff --git a/tools/distrib/python/grpcio_tools/setup.py b/tools/distrib/python/grpcio_tools/setup.py
index 0281c01796..98f03c8d64 100644
--- a/tools/distrib/python/grpcio_tools/setup.py
+++ b/tools/distrib/python/grpcio_tools/setup.py
@@ -30,6 +30,7 @@
from distutils import extension
import os
import os.path
+import shlex
import sys
import setuptools
@@ -40,6 +41,16 @@ from setuptools.command import build_ext
os.chdir(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.abspath('.'))
+# There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are
+# entirely ignored/dropped/forgotten by distutils and its Cygwin/MinGW support.
+# We use these environment variables to thus get around that without locking
+# ourselves in w.r.t. the multitude of operating systems this ought to build on.
+# By default we assume a GCC-like compiler.
+EXTRA_COMPILE_ARGS = shlex.split(os.environ.get('GRPC_PYTHON_CFLAGS',
+ '-frtti -std=c++11'))
+EXTRA_LINK_ARGS = shlex.split(os.environ.get('GRPC_PYTHON_LDFLAGS',
+ '-lpthread'))
+
import protoc_lib_deps
import grpc_version
@@ -60,7 +71,8 @@ def protoc_ext_module():
],
language='c++',
define_macros=[('HAVE_PTHREAD', 1)],
- extra_compile_args=['-lpthread', '-frtti', '-std=c++11'],
+ extra_compile_args=EXTRA_COMPILE_ARGS,
+ extra_link_args=EXTRA_LINK_ARGS,
)
return plugin_ext