Last active
October 26, 2015 08:36
-
-
Save draganHR/5e2d9bb166f70e4e535b to your computer and use it in GitHub Desktop.
Building protobuf-python v2.5.0 with C++ implementation for Centos 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install build tools | |
sudo yum -y install epel-release | |
sudo yum -y install rpm-devel rpm-build rpmdevtools python-setuptools python-devel | |
sudo yum -y install mock | |
sudo yum -y install fedora-packager | |
# Install build dependencies | |
sudo yum install automake libtool emacs emacs-el java-devel jpackage-utils maven-local maven-compiler-plugin maven-install-plugin maven-jar-plugin maven-javadoc-plugin maven-resources-plugin maven-surefire-plugin maven-antrun-plugin | |
# Add user to 'mock' group, or create new user in 'mock' group. | |
sudo usermod -a -G mock vagrant | |
rpmdev-setuptree | |
rpm --nomd5 -ih http://dl.fedoraproject.org/pub/epel/7/SRPMS/p/protobuf-2.5.0-7.el7.src.rpm | |
# Modify spec file | |
sed -i -- 's/get_python_lib()/get_python_lib(plat_specific=True)/g' ~/rpmbuild/SPECS/protobuf.spec | |
sed -i -- 's/build\/lib\/google\/protobuf\/descriptor_pb2.py/build\/lib*\/google\/protobuf\/descriptor_pb2.py/g' ~/rpmbuild/SPECS/protobuf.spec | |
sed -i -- 's/python .\/setup.py/PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp LDFLAGS="-L..\/src\/.libs" CPLUS_INCLUDE_PATH=..\/src\/ python .\/setup.py/g' ~/rpmbuild/SPECS/protobuf.spec | |
rpmbuild-md5 -bs ~/rpmbuild/SPECS/protobuf.spec | |
mock --rebuild ~/rpmbuild/SRPMS/protobuf-2.5.0-7.el7.centos.src.rpm | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
from google.protobuf.internal import cpp_message | |
except ImportError: | |
print "Fail!" | |
else: | |
print "Success!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: To use C++ implementation set
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION
tocpp
:References: