Skip to content

Commit

Permalink
Generate pyi stubs for protobuf modules for better developer experien…
Browse files Browse the repository at this point in the history
…ce (#2768)

See also: microsoft/pylance-release#351

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
  • Loading branch information
sighingnow committed May 30, 2023
1 parent 6fc7db3 commit bf8d7b0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
28 changes: 14 additions & 14 deletions k8s/internal/Makefile
Expand Up @@ -162,34 +162,34 @@ graphscope-client-manylinux2014-py3-nodocker:
if [[ "${ARCH}" == "aarch64" ]]; then \
python3 -m pip install grpcio==1.49.1 --no-binary grpcio; \
python3 -m pip install grpcio-tools==1.49.1 --no-binary grpcio-tools; \
python3 -m pip install "numpy==1.23.2" "pandas" wheel "auditwheel==5.0.0"; \
else \
python3 -m pip install "numpy==1.23.2" "pandas" "grpcio" "grpcio-tools" wheel "auditwheel==5.0.0"; \
python3 -m pip install "grpcio" "grpcio-tools"; \
fi; \
python3 -m pip install mypy-protobuf "numpy==1.23.2" "pandas" wheel "auditwheel==5.0.0"; \
elif [[ "$$py" == "cp310-cp310" ]]; then \
if [[ "${ARCH}" == "aarch64" ]]; then \
python3 -m pip install grpcio==1.49.1 --no-binary grpcio; \
python3 -m pip install grpcio-tools==1.49.1 --no-binary grpcio-tools; \
python3 -m pip install "numpy==1.21.2" "pandas" wheel "auditwheel==5.0.0"; \
else \
python3 -m pip install "numpy==1.21.2" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" wheel "auditwheel==5.0.0"; \
python3 -m pip install "grpcio>=1.49" "grpcio-tools>=1.49"; \
fi; \
python3 -m pip install mypy-protobuf "numpy==1.21.2" "pandas" wheel "auditwheel==5.0.0"; \
elif [[ "$$py" == "cp39-cp39" ]]; then \
if [[ "${ARCH}" == "aarch64" ]]; then \
python3 -m pip install grpcio==1.49.1 --no-binary grpcio; \
python3 -m pip install grpcio-tools==1.49.1 --no-binary grpcio-tools; \
python3 -m pip install "numpy==1.19.3" "pandas" wheel "auditwheel==5.0.0"; \
else \
python3 -m pip install "numpy==1.19.3" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" wheel "auditwheel==5.0.0"; \
python3 -m pip install "grpcio>=1.49" "grpcio-tools>=1.49"; \
fi; \
python3 -m pip install mypy-protobuf "numpy==1.19.3" "pandas" wheel "auditwheel==5.0.0"; \
else \
if [[ "${ARCH}" == "aarch64" ]]; then \
python3 -m pip install grpcio==1.49.1 --no-binary grpcio; \
python3 -m pip install grpcio-tools==1.49.1 --no-binary grpcio-tools; \
python3 -m pip install "numpy" "pandas" wheel "auditwheel==5.0.0"; \
else \
python3 -m pip install "numpy==1.18.5" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" wheel "auditwheel==5.0.0"; \
python3 -m pip install "grpcio>=1.49" "grpcio-tools>=1.49"; \
fi; \
python3 -m pip install mypy-protobuf "numpy" "pandas" wheel "auditwheel==5.0.0"; \
fi; \
sudo rm -rf build; \
sudo rm -rf dist/*.whl; \
Expand All @@ -214,20 +214,20 @@ graphscope-client-darwin-py3:
py=$$(python3 -V 2>&1 | awk '{print $$2}' | awk -F '.' '{print $$1$$2}') && \
pip3 install -U pip && \
if [[ "$$py" == "311" ]]; then \
pip3 install "numpy==1.23.2" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
pip3 install mypy-protobuf "numpy==1.23.2" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
elif [[ "$$py" == "310" ]]; then \
pip3 install "numpy==1.21.2" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
pip3 install mypy-protobuf "numpy==1.21.2" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
elif [[ "$$py" == "cp39-cp39" ]]; then \
if [[ "${ARCH}" == "arm64" ]]; then \
pip3 install "numpy==1.21.0" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
pip3 install mypy-protobuf "numpy==1.21.0" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
else \
pip3 install "numpy==1.19.3" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
pip3 install mypy-protobuf "numpy==1.19.3" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
fi; \
else \
if [[ "${ARCH}" == "arm64" ]]; then \
pip3 install "numpy==1.21.0" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
pip3 install mypy-protobuf "numpy==1.21.0" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
else \
pip3 install "numpy==1.18.5" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
pip3 install mypy-protobuf "numpy==1.18.5" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" delocate wheel; \
fi; \
fi; \
rm -rf build dist/*.whl || true && \
Expand Down
3 changes: 3 additions & 0 deletions python/graphscope/proto/proto_generator.py
Expand Up @@ -60,6 +60,7 @@ def python_out(relative_dir, output_dir):
"grpc_tools.protoc",
"-I%s" % ".",
"--python_out=%s" % os.path.join(output_dir),
"--mypy_out=%s" % os.path.join(output_dir),
proto_file,
],
stderr=subprocess.STDOUT,
Expand Down Expand Up @@ -96,7 +97,9 @@ def python_service_out(relative_dir, output_dir):
"grpc_tools.protoc",
"-I%s" % ".",
"--python_out=%s" % output_dir,
"--mypy_out=%s" % os.path.join(output_dir),
"--grpc_python_out=%s" % output_dir,
"--mypy_grpc_out=%s" % os.path.join(output_dir),
proto_file,
],
stderr=subprocess.STDOUT,
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools_scm", "grpcio>=1.49", "grpcio-tools>=1.49", "numpy", "wheel"]
requires = ["setuptools_scm", "grpcio>=1.49", "grpcio-tools>=1.49", "mypy-protobuf", "numpy", "wheel"]

[tool.black]
line-length = 88
Expand Down
1 change: 1 addition & 0 deletions python/requirements.txt
Expand Up @@ -4,6 +4,7 @@ grpcio>=1.49
grpcio-tools>=1.49
kubernetes>=24.2.0
msgpack
mypy-protobuf>=3.4.0
nest_asyncio
networkx==2.8.0;python_version>="3.8"
networkx==2.6.0;python_version<"3.8"
Expand Down

0 comments on commit bf8d7b0

Please sign in to comment.