|
|
|
@ -102,7 +102,7 @@ ENABLE_DOCUMENTATION_BUILD = os.environ.get( |
|
|
|
|
EXTRA_ENV_COMPILE_ARGS = os.environ.get('GRPC_PYTHON_CFLAGS', None) |
|
|
|
|
EXTRA_ENV_LINK_ARGS = os.environ.get('GRPC_PYTHON_LDFLAGS', None) |
|
|
|
|
if EXTRA_ENV_COMPILE_ARGS is None: |
|
|
|
|
EXTRA_ENV_COMPILE_ARGS = '-std=c++11' |
|
|
|
|
EXTRA_ENV_COMPILE_ARGS = '' |
|
|
|
|
if 'win32' in sys.platform and sys.version_info < (3, 5): |
|
|
|
|
# We use define flags here and don't directly add to DEFINE_MACROS below to |
|
|
|
|
# ensure that the expert user/builder has a way of turning it off (via the |
|
|
|
@ -114,7 +114,9 @@ if EXTRA_ENV_COMPILE_ARGS is None: |
|
|
|
|
EXTRA_ENV_COMPILE_ARGS += ' -D_ftime=_ftime64 -D_timeb=__timeb64' |
|
|
|
|
elif 'win32' in sys.platform: |
|
|
|
|
EXTRA_ENV_COMPILE_ARGS += ' -D_PYTHON_MSVC' |
|
|
|
|
elif "linux" in sys.platform or "darwin" in sys.platform: |
|
|
|
|
elif "linux" in sys.platform: |
|
|
|
|
EXTRA_ENV_COMPILE_ARGS += ' -std=c++11 -fvisibility=hidden -fno-wrapv' |
|
|
|
|
elif "darwin" in sys.platform: |
|
|
|
|
EXTRA_ENV_COMPILE_ARGS += ' -fvisibility=hidden -fno-wrapv' |
|
|
|
|
|
|
|
|
|
if EXTRA_ENV_LINK_ARGS is None: |
|
|
|
@ -172,7 +174,7 @@ LDFLAGS = tuple(EXTRA_LINK_ARGS) |
|
|
|
|
CFLAGS = tuple(EXTRA_COMPILE_ARGS) |
|
|
|
|
if "linux" in sys.platform or "darwin" in sys.platform: |
|
|
|
|
pymodinit_type = 'PyObject*' if PY3 else 'void' |
|
|
|
|
pymodinit = 'extern "C" __attribute__((visibility ("default"))) {}'.format(pymodinit_type) |
|
|
|
|
pymodinit = '__attribute__((visibility ("default"))) {}'.format(pymodinit_type) |
|
|
|
|
DEFINE_MACROS += (('PyMODINIT_FUNC', pymodinit),) |
|
|
|
|
|
|
|
|
|
# By default, Python3 distutils enforces compatibility of |
|
|
|
@ -192,14 +194,23 @@ def cython_extensions_and_necessity(): |
|
|
|
|
cython_module_files = [os.path.join(PYTHON_STEM, |
|
|
|
|
name.replace('.', '/') + '.pyx') |
|
|
|
|
for name in CYTHON_EXTENSION_MODULE_NAMES] |
|
|
|
|
if "darwin" in sys.platform: |
|
|
|
|
extra_objects = ['libs/opt/libares.a', |
|
|
|
|
'libs/opt/libboringssl.a', |
|
|
|
|
'libs/opt/libgpr.a', |
|
|
|
|
'libs/opt/libgrpc.a'] |
|
|
|
|
core_c_files = [] |
|
|
|
|
else: |
|
|
|
|
core_c_files = list(CORE_C_FILES) |
|
|
|
|
extra_objects = [] |
|
|
|
|
extensions = [ |
|
|
|
|
_extension.Extension( |
|
|
|
|
name=module_name, |
|
|
|
|
language='c++', |
|
|
|
|
sources=[module_file] + list(CYTHON_HELPER_C_FILES) + list(CORE_C_FILES), |
|
|
|
|
sources=[module_file] + list(CYTHON_HELPER_C_FILES) + core_c_files, |
|
|
|
|
include_dirs=list(EXTENSION_INCLUDE_DIRECTORIES), |
|
|
|
|
libraries=list(EXTENSION_LIBRARIES), |
|
|
|
|
define_macros=list(DEFINE_MACROS), |
|
|
|
|
extra_objects=extra_objects, |
|
|
|
|
extra_compile_args=list(CFLAGS), |
|
|
|
|
extra_link_args=list(LDFLAGS), |
|
|
|
|
) for (module_name, module_file) in zip(list(CYTHON_EXTENSION_MODULE_NAMES), cython_module_files) |
|
|
|
|