aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Masood Malekghassemi <atash@google.com>2016-06-29 11:14:53 -0700
committerGravatar Masood Malekghassemi <atash@google.com>2016-07-01 10:18:38 -0700
commitd5fee35f932c5aa3234d0aafaaf1e7ac7af82f3e (patch)
tree100a47cc79edc151dd13c230a1401eb129a2ee04 /tools
parent20caeb182cbc152e7e038306a9b01f438f79ca41 (diff)
Build Python3 grpcio-tools on OS X
Diffstat (limited to 'tools')
-rw-r--r--tools/distrib/python/grpcio_tools/setup.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/distrib/python/grpcio_tools/setup.py b/tools/distrib/python/grpcio_tools/setup.py
index fbe69f43d5..f9cb0534d5 100644
--- a/tools/distrib/python/grpcio_tools/setup.py
+++ b/tools/distrib/python/grpcio_tools/setup.py
@@ -31,9 +31,11 @@ from distutils import extension
import errno
import os
import os.path
+import pkg_resources
import shlex
import shutil
import sys
+import sysconfig
import setuptools
from setuptools.command import build_ext
@@ -43,6 +45,8 @@ from setuptools.command import build_ext
os.chdir(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.abspath('.'))
+PY3 = sys.version_info.major == 3
+
# 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
@@ -59,6 +63,15 @@ GRPC_PYTHON_PROTO_RESOURCES_NAME = '_proto'
import protoc_lib_deps
import grpc_version
+# By default, Python3 distutils enforces compatibility of
+# c plugins (.so files) with the OSX version Python3 was built with.
+# For Python3.4, this is OSX 10.6, but we need Thread Local Support (__thread)
+if 'darwin' in sys.platform and PY3:
+ mac_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
+ if mac_target and (pkg_resources.parse_version(mac_target) <
+ pkg_resources.parse_version('10.9.0')):
+ os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
+
def package_data():
tools_path = GRPC_PYTHON_TOOLS_PACKAGE.replace('.', os.path.sep)
proto_resources_path = os.path.join(tools_path,