aboutsummaryrefslogtreecommitdiffhomepage
path: root/python/setup.py
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2016-04-01 16:46:49 -0700
committerGravatar Jisi Liu <jisi.liu@gmail.com>2016-04-01 16:46:49 -0700
commitcba75ad40431ca0825aa59df3c9265a12c0ae3b6 (patch)
treef7ce45e0922c46eecd01a36afb6d8ec5a71c8155 /python/setup.py
parent89343d87c6a335be561fd17c8e40c72901d2f152 (diff)
parent452e2b2c5c607ab5d63cd813793f1aa960f19d1c (diff)
Merge branch 'master' of github.com:google/protobuf
Diffstat (limited to 'python/setup.py')
-rwxr-xr-xpython/setup.py35
1 files changed, 28 insertions, 7 deletions
diff --git a/python/setup.py b/python/setup.py
index 5e146161..0f4b53c4 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -157,15 +157,30 @@ class test_conformance(_build_py):
status = subprocess.check_call(cmd, shell=True)
+def get_option_from_sys_argv(option_str):
+ if option_str in sys.argv:
+ sys.argv.remove(option_str)
+ return True
+ return False
+
+
if __name__ == '__main__':
ext_module_list = []
- cpp_impl = '--cpp_implementation'
warnings_as_errors = '--warnings_as_errors'
- if cpp_impl in sys.argv:
- sys.argv.remove(cpp_impl)
+ if get_option_from_sys_argv('--cpp_implementation'):
+ # Link libprotobuf.a and libprotobuf-lite.a statically with the
+ # extension. Note that those libraries have to be compiled with
+ # -fPIC for this to work.
+ compile_static_ext = get_option_from_sys_argv('--compile_static_extension')
extra_compile_args = ['-Wno-write-strings',
'-Wno-invalid-offsetof',
'-Wno-sign-compare']
+ libraries = ['protobuf']
+ extra_objects = None
+ if compile_static_ext:
+ libraries = None
+ extra_objects = ['../src/.libs/libprotobuf.a',
+ '../src/.libs/libprotobuf-lite.a']
test_conformance.target = 'test_python_cpp'
if "clang" in os.popen('$CC --version 2> /dev/null').read():
@@ -176,16 +191,22 @@ if __name__ == '__main__':
sys.argv.remove(warnings_as_errors)
# C++ implementation extension
- ext_module_list.append(
+ ext_module_list.extend([
Extension(
"google.protobuf.pyext._message",
glob.glob('google/protobuf/pyext/*.cc'),
include_dirs=[".", "../src"],
- libraries=['protobuf'],
+ libraries=libraries,
+ extra_objects=extra_objects,
library_dirs=['../src/.libs'],
extra_compile_args=extra_compile_args,
- )
- )
+ ),
+ Extension(
+ "google.protobuf.internal._api_implementation",
+ glob.glob('google/protobuf/internal/api_implementation.cc'),
+ extra_compile_args=['-DPYTHON_PROTO2_CPP_IMPL_V2'],
+ ),
+ ])
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp'
# Keep this list of dependencies in sync with tox.ini.