From 1e521faf6c4c225a2b9e98d2137b754243e19a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E6=97=AD=E6=98=9FAstrum=20Kuo?= Date: Wed, 8 Apr 2015 16:42:23 +0800 Subject: [PATCH] change --python_out to packagedir, add --proto_path/-I option, add some hint when not need generating pb2 file. --- protobuf_setuptools.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/protobuf_setuptools.py b/protobuf_setuptools.py index d56be1a..0de6a52 100644 --- a/protobuf_setuptools.py +++ b/protobuf_setuptools.py @@ -2,9 +2,10 @@ import sys import subprocess -from os import path as op +from os import path as op from distutils.spawn import find_executable from setuptools.command.build_py import build_py +from datetime import datetime class ProtoBuild(build_py): @@ -39,6 +40,11 @@ def run(self): if (not op.exists(output) or (op.getmtime(source) > op.getmtime(output))): sys.stderr.write('Protobuf-compiling ' + source + '\n') - subprocess.check_call([self.find_protoc(), '--python_out=.', source]) - - + subprocess.check_call([self.find_protoc(), + '--python_out=%s' % packagedir, + '-I%s' % packagedir, + source]) + else: + sys.stderr.write("Proto file %s already generated at %s, pass\n" % + (output, + datetime.fromtimestamp(op.getmtime(output))))