8000 Create script to generate s2clientprotocol protobuf stubs by Avasam · Pull Request #11772 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Create script to generate s2clientprotocol protobuf stubs #11772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'main' of https://github.com/python/typeshed into s2clie…
…ntprotocol-proto-gen
  • Loading branch information
Avasam committed Apr 21, 2024
commit be945bbbe043d67c54eca6f3a885e91d14f4ce4c
9 changes: 2 additions & 7 deletions scripts/generate_proto_stubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,8 @@ set -ex -o pipefail
PROTOBUF_VERSION=26.1
MYPY_PROTOBUF_VERSION=3.6.0

if uname -a | grep Darwin; then
# brew install coreutils wget
PLAT=osx
else
# sudo apt install -y unzip
PLAT=linux
fi
# brew install coreutils wget
# sudo apt install -y unzip
REPO_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)"
TMP_DIR="$(mktemp -d)"
PYTHON_PROTOBUF_FILENAME="protobuf-$PROTOBUF_VERSION.zip"
Expand Down
20 changes: 8 additions & 12 deletions scripts/sync_s2clientprotocol_protobuf_stubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,18 @@ set -euxo pipefail
S2CLIENT_PROTO_VERSION=c04df4adbe274858a4eb8417175ee32ad02fd609
MYPY_PROTOBUF_VERSION=3.6.0

if uname -a | grep Darwin; then
# brew install coreutils wget
PLAT=osx
else
# sudo apt install -y unzip
PLAT=linux
fi
REPO_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)"
TMP_DIR="$(mktemp -d)"
S2CLIENT_PROTO_FILENAME="$S2CLIENT_PROTO_VERSION.zip"
S2CLIENT_PROTO_URL="https://github.com/Blizzard/s2client-proto/archive/$S2CLIENT_PROTO_FILENAME"
S2CLIENT_PROTO_DIR="s2client-proto-$S2CLIENT_PROTO_VERSION"

cd "$TMP_DIR"
echo "Working in $TMP_DIR"

# s2client works on very old protoc versions, down to 2.6
protoc --version

# Fetch s2clientprotocol (which contains all the .proto files)
wget "$S2CLIENT_PROTO_URL"
unzip "$S2CLIENT_PROTO_FILENAME"
S2CLIENT_PROTO_DIR="s2client-proto-$S2CLIENT_PROTO_VERSION"

# Prepare virtualenv
python3 -m venv .venv
Expand All @@ -41,6 +31,9 @@ python3 -m pip install pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION"
# Remove existing pyi
find "$REPO_ROOT/stubs/s2clientprotocol/" -name "*_pb2.pyi" -delete

# s2client works on very old protoc versions, down to 2.6. So we can use the system's protoc.
PROTOC_VERSION=$(protoc --version)
echo $PROTOC_VERSION
protoc \
--proto_path="$S2CLIENT_PROTO_DIR" \
--mypy_out "relax_strict_optional_primitives:$REPO_ROOT/stubs/s2clientprotocol" \
Expand All @@ -58,7 +51,10 @@ rm -rf "$TMP_DIR"
cd "$REPO_ROOT"

sed --in-place="" \
"s/extra_description = .*$/extra_description = \"Partially generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on [s2client-proto $PYTHON_S2CLIENT_PROTO_VERSION](https:\/\/github.com\/Blizzard\/s2client-proto\/tree\/$S2CLIENT_PROTO_VERSION)\"/" \
"s/extra_description = .*$/extra_description = \"\
Partially generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) \
and $PROTOC_VERSION \
on [s2client-proto $PYTHON_S2CLIENT_PROTO_VERSION](https:\/\/github.com\/Blizzard\/s2client-proto\/tree\/$S2CLIENT_PROTO_VERSION)\"/" \
stubs/s2clientprotocol/METADATA.toml

# use `|| true` so the script still continues even if a pre-commit hook
Expand Down
16 changes: 6 additions & 10 deletions scripts/sync_tensorflow_protobuf_stubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@ set -euxo pipefail
TENSORFLOW_VERSION=2.12.1
MYPY_PROTOBUF_VERSION=3.6.0

if uname -a | grep Darwin; then
# brew install coreutils wget
PLAT=osx
else
# sudo apt install -y unzip
PLAT=linux
fi
# brew install coreutils wget
# sudo apt install -y unzip
REPO_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)"
TMP_DIR="$(mktemp -d)"
PROTOC_FILENAME="protoc-$PROTOBUF_VERSION-$PLAT-x86_64.zip"
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/$PROTOC_FILENAME"
TENSORFLOW_FILENAME="v$TENSORFLOW_VERSION.zip"
TENSORFLOW_URL="https://github.com/tensorflow/tensorflow/archive/refs/tags/$TENSORFLOW_FILENAME"
TENSORFLOW_DIR="tensorflow-$TENSORFLOW_VERSION"
Expand Down Expand Up @@ -84,7 +77,10 @@ rm \
stubs/tensorflow/tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi \

sed --in-place="" \
"s/extra_description = .*$/extra_description = \"Partially generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on tensorflow==$TENSORFLOW_VERSION\"/" \
"s/extra_description = .*$/extra_description = \"\
Partially generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) \
and $PROTOC_VERSION \
on tensorflow==$TENSORFLOW_VERSION.\"/" \
stubs/tensorflow/METADATA.toml

# use `|| true` so the script still continues even if a pre-commit hook
Expand Down
2 changes: 1 addition & 1 deletion stubs/s2clientprotocol/METADATA.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
version = "5.*"
upstream_repository = "https://github.com/Blizzard/s2client-proto"
requires = ["types-protobuf"]
extra_description = "Partially generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) on [s2client-proto 5.0.12.91115.0](https://github.com/Blizzard/s2client-proto/tree/c04df4adbe274858a4eb8417175ee32ad02fd609)"
extra_description = "Partially generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) and libprotoc 3.6.1 on [s2client-proto 5.0.12.91115.0](https://github.com/Blizzard/s2client-proto/tree/c04df4adbe274858a4eb8417175ee32ad02fd609)"
You are viewing a condensed version of this merge commit. You can view the full changes here.
0