资源简介
linux protobuf
linux protobuf
linux protobuf
linux protobuf
代码片段和文件信息
#! /usr/bin/python
#
# See README for usage instructions.
import sys
import os
import subprocess
# We must use setuptools not distutils because we need to use the
# namespace_packages option for the “google“ package.
try:
from setuptools import setup Extension
except ImportError:
try:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup Extension
except ImportError:
sys.stderr.write(
“Could not import setuptools; make sure you have setuptools or “
“ez_setup installed.\n“)
raise
from distutils.command.clean import clean as _clean
from distutils.command.build_py import build_py as _build_py
from distutils.spawn import find_executable
maintainer_email = “protobuf@googlegroups.com“
# Find the Protocol Compiler.
if os.path.exists(“../src/protoc“):
protoc = “../src/protoc“
elif os.path.exists(“../src/protoc.exe“):
protoc = “../src/protoc.exe“
elif os.path.exists(“../vsprojects/Debug/protoc.exe“):
protoc = “../vsprojects/Debug/protoc.exe“
elif os.path.exists(“../vsprojects/Release/protoc.exe“):
protoc = “../vsprojects/Release/protoc.exe“
else:
protoc = find_executable(“protoc“)
def generate_proto(source):
“““Invokes the Protocol Compiler to generate a _pb2.py from the given
.proto file. Does nothing if the output already exists and is newer than
the input.“““
output = source.replace(“.proto“ “_pb2.py“).replace(“../src/“ ““)
if (not os.path.exists(output) or
(os.path.exists(source) and
os.path.getmtime(source) > os.path.getmtime(output))):
print “Generating %s...“ % output
if not os.path.exists(source):
sys.stderr.write(“Can‘t find required file: %s\n“ % source)
sys.exit(-1)
if protoc == None:
sys.stderr.write(
“protoc is not installed nor found in ../src. Please compile it “
“or install the binary package.\n“)
sys.exit(-1)
protoc_command = [ protoc “-I../src“ “-I.“ “--python_out=.“ source ]
if subprocess.call(protoc_command) != 0:
sys.exit(-1)
def MakeTestSuite():
# This is apparently needed on some systems to make sure that the tests
# work even if a previous version is already installed.
if ‘google‘ in sys.modules:
del sys.modules[‘google‘]
generate_proto(“../src/google/protobuf/unittest.proto“)
generate_proto(“../src/google/protobuf/unittest_custom_options.proto“)
generate_proto(“../src/google/protobuf/unittest_import.proto“)
generate_proto(“../src/google/protobuf/unittest_mset.proto“)
generate_proto(“../src/google/protobuf/unittest_no_generic_services.proto“)
generate_proto(“google/protobuf/internal/more_extensions.proto“)
generate_proto(“google/protobuf/internal/more_messages.proto“)
import unittest
import google.protobuf.internal.generator_test as generator_test
import google.protobuf.internal.descriptor_test as descriptor_test
import google.protobuf.internal.reflection_test as reflection_test
import google.pr
- 上一篇:LPC2132 串口程序
- 下一篇:自动控制原理王万良版答案
相关资源
- 将protobuf移植到32位单片机.pdf
- protobuf-dt
- Google的protobuf,可以安装
- protobuf-decoder-master.zip
- protoc3.5protobuf3;.5
- protobuf-net的代码生成工具ProtoGen
- protobuf-wireshark测试消息
- protobuf 协议文件生成器
- protobuf-3.1.0.tar.gz
- 抖音推荐接口v2版本新版
- protobuf2.5 protoc.exe libprotoc.lib libprotob
- opencv3.2 protobuf-cpp-3.1.0.tar.gz
- protobuf-all-3.6.1.zip
- protobuf-all-3.6.0.tar.gz
- protobuf-cpp-3.1.0.tar.gz
- protobuf_2_6_1.tar.gz
- protobuf枚举和包的使用
- protobuf-2.5.0
- protobuf 2.6.1
评论
共有 条评论