Skip to content

Commit

Permalink
Modify setup.py to build protos on Windows
Browse files Browse the repository at this point in the history
Also change yaml library to one that builds on Windows
  • Loading branch information
Daiwei Li committed Feb 15, 2018
1 parent cea0dbe commit 3a3a8f8
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 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 @@ -63,19 +64,23 @@ 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
prefix = None

maybe_protoc = os.path.join(prefix, 'bin', 'protoc')
if os.path.isfile(maybe_protoc) and os.access(maybe_protoc, os.X_OK):
self.protoc = None
if prefix:
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
else:
else:
print('Warning: protoc not found at %s' % maybe_protoc)
print('setup will attempt to run protoc with no prefix.')
self.protoc = 'protoc'
if not self.protoc:
self.protoc = find_executable('protoc')
pc_path = os.path.dirname(find_executable('protoc'))
self.protodir = os.path.abspath(os.path.dirname(pc_path) + '/../lib')

self.protodir = os.path.join(prefix, 'include')
else:
self.protodir = os.path.join(prefix, 'include')
self.indir = os.getcwd()
self.outdir = os.getcwd()

Expand Down Expand Up @@ -109,6 +114,9 @@ def run(self):
'"protobuf-compiler" and "libprotobuf-dev" packages.')
elif sys.platform == 'darwin':
print('On Mac, protobuf is often installed via homebrew.')
else:
print('On Windows, protoc should be installed and added '
'to the path.')
raise
except subprocess.CalledProcessError:
print('Could not build proto files.')
Expand All @@ -130,7 +138,7 @@ def run(self):
'mutablerecords>=0.4.1,<2.0',
'oauth2client>=1.5.2,<2.0',
'protobuf>=3.0.0,<4.0',
'pyaml>=15.3.1,<16.0',
'PyYAML>=3.10,<4.0',
'pyOpenSSL>=17.1.0,<18.0',
'sockjs-tornado>=1.0.3,<2.0',
'tornado>=4.3,<5.0',
Expand Down

0 comments on commit 3a3a8f8

Please sign in to comment.