forked from sandbox-quantum/sandwich
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
39 lines (28 loc) · 951 Bytes
/
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
# Copyright (c) SandboxAQ. All rights reserved.
# SPDX-License-Identifier: AGPL-3.0-only
import os
from pathlib import Path
from grpc_tools import protoc
from setuptools import setup
from setuptools.command.build_py import build_py
from wheel.bdist_wheel import bdist_wheel
SCRIPT_DIR = Path(os.path.realpath(__file__)).parent.resolve()
def generate_protos():
cwd = os.getcwd()
os.chdir(SCRIPT_DIR)
for proto in Path("pysandwich").rglob("*.proto"):
protoc.main(["-I.", str(proto), "--python_out=."])
os.chdir(cwd)
class BuildPyCommand(build_py):
def run(self):
generate_protos()
build_py.run(self)
class BDistWheelCommand(bdist_wheel):
def run(self):
generate_protos()
bdist_wheel.run(self)
setup(
name="pysandwich",
packages=["pysandwich", "pysandwich.proto", "pysandwich.proto.api.v1"],
cmdclass={"build_py": BuildPyCommand, "bdist_wheel": BDistWheelCommand},
)