From a676b43def0b399fe5d881da6eeb420e070e3b51 Mon Sep 17 00:00:00 2001 From: Achal Shah Date: Tue, 15 Mar 2022 11:23:03 -0700 Subject: [PATCH] fix: Create __init__ files for the proto-generated python dirs Signed-off-by: Achal Shah --- Makefile | 2 +- sdk/python/setup.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 15ac930472..f65d07bbdf 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ package-protos: cp -r ${ROOT_DIR}/protos ${ROOT_DIR}/sdk/python/feast/protos compile-protos-python: - python setup.py build_python_protos + python sdk/python/setup.py build_python_protos install-python: cd sdk/python && python -m piptools sync requirements/py$(PYTHON)-requirements.txt diff --git a/sdk/python/setup.py b/sdk/python/setup.py index e4fe7ea946..da624ae404 100644 --- a/sdk/python/setup.py +++ b/sdk/python/setup.py @@ -210,13 +210,21 @@ def _generate_python_protos(self, path: str): self.python_folder, ] + proto_files, - ) + ) def run(self): + from pathlib import Path + for sub_folder in self.sub_folders: self._generate_python_protos(f"feast/{sub_folder}/*.proto") - - from pathlib import Path + # We need the __init__ files for each of the generated subdirs + # so that they are regular packages, and don't need the `--namespace-packages` flags + # when being typechecked using mypy. BUT, we need to exclude `types` because that clashes + # with an existing module in the python standard library. + if sub_folder == "types": + continue + with open(f"{self.python_folder}/feast/{sub_folder}/__init__.py", 'w'): + pass for path in Path("feast/protos").rglob("*.py"): for folder in self.sub_folders: