Skip to content

Commit

Permalink
Fix pip installs on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
arsharma1 committed May 14, 2019
1 parent 655e85d commit b583084
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand All @@ -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'))
Expand Down

0 comments on commit b583084

Please sign in to comment.