forked from cloudstateio/python-support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
76 lines (61 loc) · 2.16 KB
/
setup.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
Copyright 2020 Lightbend Inc.
Licensed under the Apache License, Version 2.0.
"""
import os
import pathlib
from setuptools import find_packages, setup
# Load version in cloudstate package.
from setuptools.command.build_py import build_py
exec(open("cloudstate/version.py").read())
PROTOBUF_VERSION = "master"
version = __version__ # noqa
name = "cloudstate"
print(f"package name: {name}, version: {version}", flush=True)
proto_lib_roots = ["protobuf/lib"]
proto_roots = ["."]
class FetchBuildProtosCommand(build_py):
"""fetch libs and install the protocol buffer generated sources."""
def run(self):
os.system(f"scripts/fetch-cloudstate-pb.sh {PROTOBUF_VERSION}")
for proto_root in proto_roots + proto_lib_roots:
for root, subdirs, files in os.walk(proto_root):
for file in [f for f in files if f.endswith(".proto")]:
file_path = pathlib.Path(root) / file
destination = "."
print(f"compiling {file_path} to {destination}")
command = f"python -m grpc_tools.protoc {' '.join([' -I ' + i for i in proto_roots + proto_lib_roots])} --python_out={destination} --grpc_python_out={destination} {file_path}" # noqa
os.system(command)
return super().run()
packages = find_packages(exclude=[])
print(f"packages: {packages}")
setup(
name=name,
version=version,
url="https://github.com/cloudstateio/python-support",
license="Apache 2.0",
description="Cloudstate Python Support Library",
packages=packages,
package_data={
"": ["*.proto"],
},
long_description=open("Description.md", "r").read(),
long_description_content_type="text/markdown",
zip_safe=False,
scripts=["scripts/fetch-cloudstate-pb.sh"],
install_requires=[
"attrs>=19.3.0",
"google-api>=0.1.12",
"googleapis-common-protos >= 1.51.0",
"grpcio>=1.31.0",
"grpcio-tools>=1.31.0",
"protobuf>=3.11.3",
"pytest>=5.4.2",
"six>=1.14.0",
"grpcio-reflection>=1.31.0",
"docker",
],
cmdclass={
"build_py": FetchBuildProtosCommand,
},
)