Skip to content

Commit b583084

Browse files
committed
Fix pip installs on Windows.
1 parent 655e85d commit b583084

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

setup.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from distutils.command.build import build
2424
from distutils.command.clean import clean
2525
from distutils.cmd import Command
26+
from distutils.spawn import find_executable
2627
from setuptools import find_packages
2728
from setuptools import setup
2829
from setuptools.command.test import test
@@ -51,7 +52,8 @@ class BuildProtoCommand(Command):
5152
('outdir=', 'o', 'Where to output .py files.')]
5253

5354
def initialize_options(self):
54-
self.skip_proto = False
55+
self.indir = os.getcwd()
56+
self.outdir = os.getcwd()
5557
try:
5658
prefix = subprocess.check_output(
5759
'pkg-config --variable prefix protobuf'.split()).strip().decode('utf-8')
@@ -63,30 +65,27 @@ def initialize_options(self):
6365
# Default to /usr/local for Homebrew
6466
prefix = '/usr/local'
6567
else:
66-
print('Warning: mfg-inspector output is not fully implemented for '
67-
'Windows. OpenHTF will be installed without it.')
68-
self.skip_proto = True
68+
# Handle installing on Windows.
69+
self.protoc = find_executable('protoc')
70+
self.protodir = os.path.join(
71+
os.path.dirname(os.path.dirname(os.path.dirname(self.protoc))),
72+
'lib')
73+
return
6974

7075
maybe_protoc = os.path.join(prefix, 'bin', 'protoc')
7176
if os.path.isfile(maybe_protoc) and os.access(maybe_protoc, os.X_OK):
72-
self.protoc = maybe_protoc
77+
self.protoc = maybe_protoc
7378
else:
74-
print('Warning: protoc not found at %s' % maybe_protoc)
75-
print('setup will attempt to run protoc with no prefix.')
76-
self.protoc = 'protoc'
79+
print('Warning: protoc not found at %s' % maybe_protoc)
80+
print('setup will attempt to run protoc with no prefix.')
81+
self.protoc = 'protoc'
7782

7883
self.protodir = os.path.join(prefix, 'include')
79-
self.indir = os.getcwd()
80-
self.outdir = os.getcwd()
8184

8285
def finalize_options(self):
8386
pass
8487

8588
def run(self):
86-
if self.skip_proto:
87-
print('Skipping building protocol buffers.')
88-
return
89-
9089
# Build regular proto files.
9190
protos = glob.glob(
9291
os.path.join(self.indir, 'openhtf', 'output', 'proto', '*.proto'))

0 commit comments

Comments
 (0)