setup.py: fix for issue #96

This commit is contained in:
Domenico Iezzi 2019-11-25 17:55:26 +01:00
parent a686f556e3
commit ac404b34f6
No known key found for this signature in database
GPG Key ID: 6E357572D6E9F89C

View File

@ -4,8 +4,9 @@ from setuptools.command.build_py import build_py as _build
import os.path import os.path
import subprocess import subprocess
import shutil
PROTOC_BIN = "/usr/bin/protoc" PROTOC_EXEC = "protoc"
CURRENT_DIR = os.path.abspath( os.path.dirname( __file__ ) ) CURRENT_DIR = os.path.abspath( os.path.dirname( __file__ ) )
@ -13,11 +14,12 @@ class ProtobufBuilder(_build):
def run(self): def run(self):
# check if protobuf is installed # check if protobuf is installed
if not os.path.isfile(PROTOC_BIN): exec_path = shutil.which(PROTOC_EXEC)
if exec_path is None:
raise Exception("You should install protobuf compiler") raise Exception("You should install protobuf compiler")
print("Building protobuf file") print("Building protobuf file")
subprocess.run([PROTOC_BIN, subprocess.run([exec_path,
"--proto_path=" + CURRENT_DIR, "--proto_path=" + CURRENT_DIR,
"--python_out=" + CURRENT_DIR + "/gpapi/", "--python_out=" + CURRENT_DIR + "/gpapi/",
CURRENT_DIR + "/googleplay.proto"]) CURRENT_DIR + "/googleplay.proto"])