Skip to content

Commit a10733d

Browse files
committed
Modify setup.py to build protos on Windows
Also change yaml library to one that builds on Windows
1 parent cea0dbe commit a10733d

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

setup.py

Lines changed: 17 additions & 9 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
@@ -63,19 +64,23 @@ def initialize_options(self):
6364
# Default to /usr/local for Homebrew
6465
prefix = '/usr/local'
6566
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
67+
prefix = None
6968

70-
maybe_protoc = os.path.join(prefix, 'bin', 'protoc')
71-
if os.path.isfile(maybe_protoc) and os.access(maybe_protoc, os.X_OK):
69+
self.protoc = None
70+
if prefix:
71+
maybe_protoc = os.path.join(prefix, 'bin', 'protoc')
72+
if os.path.isfile(maybe_protoc) and os.access(maybe_protoc, os.X_OK):
7273
self.protoc = maybe_protoc
73-
else:
74+
else:
7475
print('Warning: protoc not found at %s' % maybe_protoc)
7576
print('setup will attempt to run protoc with no prefix.')
76-
self.protoc = 'protoc'
77+
if not self.protoc:
78+
self.protoc = find_executable('protoc')
79+
pc_path = os.path.dirname(find_executable('protoc'))
80+
self.protodir = os.path.abspath(os.path.dirname(pc_path) + '/../lib')
7781

78-
self.protodir = os.path.join(prefix, 'include')
82+
else:
83+
self.protodir = os.path.join(prefix, 'include')
7984
self.indir = os.getcwd()
8085
self.outdir = os.getcwd()
8186

@@ -109,6 +114,9 @@ def run(self):
109114
'"protobuf-compiler" and "libprotobuf-dev" packages.')
110115
elif sys.platform == 'darwin':
111116
print('On Mac, protobuf is often installed via homebrew.')
117+
else:
118+
print('On Windows, protoc should be installed and added '
119+
'to the path.')
112120
raise
113121
except subprocess.CalledProcessError:
114122
print('Could not build proto files.')
@@ -130,7 +138,7 @@ def run(self):
130138
'mutablerecords>=0.4.1,<2.0',
131139
'oauth2client>=1.5.2,<2.0',
132140
'protobuf>=3.0.0,<4.0',
133-
'pyaml>=15.3.1,<16.0',
141+
'PyYAML>=3.10,<4.0',
134142
'pyOpenSSL>=17.1.0,<18.0',
135143
'sockjs-tornado>=1.0.3,<2.0',
136144
'tornado>=4.3,<5.0',

0 commit comments

Comments
 (0)