From b58308423864f16940d3c8ac2d3a7805f2b85dd2 Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Tue, 14 May 2019 10:31:41 -0700 Subject: [PATCH] Fix pip installs on Windows. --- setup.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/setup.py b/setup.py index 7c248bb84..f31746d3b 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,7 @@ from distutils.command.build import build from distutils.command.clean import clean from distutils.cmd import Command +from distutils.spawn import find_executable from setuptools import find_packages from setuptools import setup from setuptools.command.test import test @@ -51,7 +52,8 @@ class BuildProtoCommand(Command): ('outdir=', 'o', 'Where to output .py files.')] def initialize_options(self): - self.skip_proto = False + self.indir = os.getcwd() + self.outdir = os.getcwd() try: prefix = subprocess.check_output( 'pkg-config --variable prefix protobuf'.split()).strip().decode('utf-8') @@ -63,30 +65,27 @@ def initialize_options(self): # Default to /usr/local for Homebrew prefix = '/usr/local' else: - print('Warning: mfg-inspector output is not fully implemented for ' - 'Windows. OpenHTF will be installed without it.') - self.skip_proto = True + # Handle installing on Windows. + self.protoc = find_executable('protoc') + self.protodir = os.path.join( + os.path.dirname(os.path.dirname(os.path.dirname(self.protoc))), + 'lib') + return maybe_protoc = os.path.join(prefix, 'bin', 'protoc') if os.path.isfile(maybe_protoc) and os.access(maybe_protoc, os.X_OK): - self.protoc = maybe_protoc + self.protoc = maybe_protoc else: - print('Warning: protoc not found at %s' % maybe_protoc) - print('setup will attempt to run protoc with no prefix.') - self.protoc = 'protoc' + print('Warning: protoc not found at %s' % maybe_protoc) + print('setup will attempt to run protoc with no prefix.') + self.protoc = 'protoc' self.protodir = os.path.join(prefix, 'include') - self.indir = os.getcwd() - self.outdir = os.getcwd() def finalize_options(self): pass def run(self): - if self.skip_proto: - print('Skipping building protocol buffers.') - return - # Build regular proto files. protos = glob.glob( os.path.join(self.indir, 'openhtf', 'output', 'proto', '*.proto'))