mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-03-16 19:46:13 +08:00
Bump protobuf to v24.4 and update generator script (#11693)
This commit is contained in:
@@ -11,8 +11,7 @@ set -ex -o pipefail
|
||||
# followed by committing the changes to typeshed
|
||||
#
|
||||
# Update these two variables when rerunning script
|
||||
PROTOBUF_VERSION=21.8
|
||||
PYTHON_PROTOBUF_VERSION=4.21.8
|
||||
PROTOBUF_VERSION=24.4
|
||||
MYPY_PROTOBUF_VERSION=3.5.0
|
||||
|
||||
if uname -a | grep Darwin; then
|
||||
@@ -23,10 +22,10 @@ else
|
||||
fi
|
||||
REPO_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
PYTHON_PROTOBUF_FILENAME="protobuf-python-${PYTHON_PROTOBUF_VERSION}.zip"
|
||||
PROTOC_FILENAME="protoc-${PROTOBUF_VERSION}-${PLAT}-x86_64.zip"
|
||||
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/$PROTOC_FILENAME"
|
||||
PYTHON_PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/$PYTHON_PROTOBUF_FILENAME"
|
||||
PYTHON_PROTOBUF_FILENAME="protobuf-$PROTOBUF_VERSION.zip"
|
||||
PROTOC_FILENAME="protoc-$PROTOBUF_VERSION-$PLAT-x86_64.zip"
|
||||
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/$PROTOC_FILENAME"
|
||||
PYTHON_PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/$PYTHON_PROTOBUF_FILENAME"
|
||||
|
||||
cd "$TMP_DIR"
|
||||
echo "Working in $TMP_DIR"
|
||||
@@ -39,7 +38,7 @@ unzip "$PROTOC_FILENAME" -d protoc_install
|
||||
# Fetch protoc-python (which contains all the .proto files)
|
||||
wget "$PYTHON_PROTOBUF_URL"
|
||||
unzip "$PYTHON_PROTOBUF_FILENAME"
|
||||
PYTHON_PROTOBUF_DIR="protobuf-$PYTHON_PROTOBUF_VERSION"
|
||||
PYTHON_PROTOBUF_DIR="protobuf-$PROTOBUF_VERSION"
|
||||
|
||||
# Prepare virtualenv
|
||||
VENV=venv
|
||||
@@ -70,10 +69,17 @@ PROTO_FILES=$(grep "GenProto.*google" $PYTHON_PROTOBUF_DIR/python/setup.py | \
|
||||
# shellcheck disable=SC2086
|
||||
protoc_install/bin/protoc --proto_path="$PYTHON_PROTOBUF_DIR/src" --mypy_out="relax_strict_optional_primitives:$REPO_ROOT/stubs/protobuf" $PROTO_FILES
|
||||
|
||||
# use `|| true` so the script still continues even if a pre-commit hook
|
||||
# applies autofixes (which will result in a nonzero exit code)
|
||||
pre-commit run --files "$REPO_ROOT/stubs/protobuf" || true
|
||||
PYTHON_PROTOBUF_VERSION=$(jq -r '.[] | .languages.python' "$PYTHON_PROTOBUF_DIR/version.json")
|
||||
|
||||
sed --in-place="" \
|
||||
"s/extra_description = .*$/extra_description = \"Generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on protobuf==$PYTHON_PROTOBUF_VERSION\"/" \
|
||||
"s/extra_description = .*$/extra_description = \"Generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on [protobuf v$PROTOBUF_VERSION](https:\/\/github.com\/protocolbuffers\/protobuf\/releases\/tag\/v$PROTOBUF_VERSION) (python protobuf==$PYTHON_PROTOBUF_VERSION)\"/" \
|
||||
"$REPO_ROOT/stubs/protobuf/METADATA.toml"
|
||||
|
||||
# Must be run in a git repository
|
||||
cd $REPO_ROOT
|
||||
# use `|| true` so the script still continues even if a pre-commit hook
|
||||
# applies autofixes (which will result in a nonzero exit code)
|
||||
pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/protobuf") || true
|
||||
# Ruff takes two passes to fix everything, re-running all of pre-commit is *slow*
|
||||
# and we don't need --unsafe-fixes to remove imports
|
||||
ruff check "$REPO_ROOT/stubs/protobuf" --fix --exit-zero
|
||||
|
||||
@@ -61,9 +61,6 @@ rm tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \
|
||||
tensorflow/core/protobuf/worker_service_pb2.pyi \
|
||||
tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi
|
||||
|
||||
# use `|| true` so the script still continues even if a pre-commit hook
|
||||
# applies autofixes (which will result in a nonzero exit code)
|
||||
pre-commit run --files "$REPO_ROOT/stubs/tensorflow/tensorflow" || true
|
||||
|
||||
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\"/" \
|
||||
@@ -71,3 +68,12 @@ sed --in-place="" \
|
||||
|
||||
# Cleanup last. If the script fails halfway, it's nice to be able to re-run it immediately
|
||||
rm -rf repository/
|
||||
|
||||
# Must be run in a git repository
|
||||
cd $REPO_ROOT
|
||||
# use `|| true` so the script still continues even if a pre-commit hook
|
||||
# applies autofixes (which will result in a nonzero exit code)
|
||||
pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/tensorflow/tensorflow") || true
|
||||
# Ruff takes two passes to fix everything, re-running all of pre-commit is *slow*
|
||||
# and we don't need --unsafe-fixes to remove imports
|
||||
ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix --exit-zero
|
||||
|
||||
Reference in New Issue
Block a user