Skip to content

Commit

Permalink
fix: Create __init__ files for the proto-generated python dirs
Browse files Browse the repository at this point in the history
Signed-off-by: Achal Shah <achals@gmail.com>
  • Loading branch information
achals committed Mar 15, 2022
1 parent c2389da commit a676b43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions sdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a676b43

Please sign in to comment.