Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
cf828deb
Commit
cf828deb
authored
Mar 25, 2016
by
Manjunath Kudlur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Linking the cpp implementation extension statically with libprotobuf
parent
81eb84c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
17 deletions
+30
-17
README.md
python/README.md
+2
-10
setup.py
python/setup.py
+28
-7
No files found.
python/README.md
View file @
cf828deb
...
...
@@ -123,13 +123,5 @@ C++ Implementation
The C++ implementation for Python messages is built as a Python extension to
improve the overall protobuf Python performance.
To use the C++ implementation, you need to:
1) Install the C++ protobuf runtime library, please see instructions in the
parent directory.
2) Export an environment variable:
$ export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
You must set this variable at runtime, before running your program, otherwise
the pure-Python implementation will be used. In a future release, we will
change the default so that C++ implementation is used whenever it is available.
To use the C++ implementation, you need to install the C++ protobuf runtime
library, please see instructions in the parent directory.
python/setup.py
View file @
cf828deb
...
...
@@ -157,13 +157,28 @@ 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'
]
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
():
...
...
@@ -174,16 +189,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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment