This repository was archived by the owner on Sep 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·57 lines (46 loc) · 1.58 KB
/
setup.py
File metadata and controls
executable file
·57 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /usr/bin/env python
import distutils.cmd
import distutils.log
import setuptools
import subprocess
import os
class GrpcCommand(distutils.cmd.Command):
"""A custom command to generate grpc modules"""
user_options = []
description = 'download proto file run grpctools'
def initialize_options(self):
self.clean('proto')
def clean(self,dir):
if not os.path.exists(dir):
os.mkdir(dir, 0777)
else:
for file in os.listdir(dir):
file_path = os.path.join(dir, file)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
except Exception as e:
print(e)
def finalize_options(self):
pass
def run(self):
"""Run command."""
command = ["wget", "https://raw.githubusercontent.com/projectriff/function-proto/master/function.proto", "-P",
"proto"]
self.announce(
'Running command: %s' % str(command),
level=distutils.log.INFO)
subprocess.check_call(command)
command = ["python", "-m", "grpc_tools.protoc", "-I./proto", "--python_out=invoker", "--grpc_python_out=invoker",
"./proto/function.proto"]
self.announce(
'Running command: %s' % str(command),
level=distutils.log.INFO)
subprocess.check_call(command)
setuptools.setup(
test_suite="tests",
tests_require=['grpcio==1.8.4','grpcio_tools==1.8.4','protobuf','futures'],
cmdclass={
'grpc': GrpcCommand,
},
)