- Regen requirements.bazel.lock with Python 3.9
- bump isort to 6.0.1 (except in pylint, which needs to be updated separately)
- fix python version specifiers for black, isort and pylint, typeguard
- fix default ignore patterns for isort and pylint
- consistent debug info: python version, pip list
- consistent virtualenv naming: `.venv-ci-*`
- bazel: bump typeguard to 4.4.2
- bazel: bumped gevent to `25.9.1`, greenlet to `3.2.4` to support Python 3.13, closes #40685
- bazel: bump pyyaml for python 3.14 support
- bazel: take care of temporary pins to support 3.8-based CIs
Bazel RBE CIs upgraded in the following changelists, and currently run Python 3.10:
- cl/
845778848
- cl/
845816768
Relevant testing was done in #41239.
Closes #40323
PiperOrigin-RevId:
846423001
[MAIN]
+py-version = 3.9
load-plugins=
pylint.extensions.no_self_use,
pylint.extensions.comparison_placement,
src/python/grpcio/grpc/framework/common,
src/python/grpcio/grpc/framework/foundation,
src/python/grpcio/grpc/framework/interfaces,
+ignore-patterns=
+ .*pb2\.py,
+ .*pb2_grpc\.py,
extension-pkg-whitelist=grpc._cython.cygrpc
[MAIN]
+py-version = 3.9
load-plugins=
pylint.extensions.no_self_use,
pylint.extensions.comparison_placement,
src/python/grpcio/grpc/framework/common,
src/python/grpcio/grpc/framework/foundation,
src/python/grpcio/grpc/framework/interfaces,
+ignore-patterns=
+ .*pb2\.py,
+ .*pb2_grpc\.py,
[VARIABLES]
[MAIN]
+py-version = 3.9
load-plugins=
pylint.extensions.no_self_use,
pylint.extensions.comparison_placement,
src/python/grpcio_tests/tests/unit/framework,
src/python/grpcio_tests/tests/unit/framework/common,
src/python/grpcio_tests/tests/unit/framework/foundation,
+ignore-patterns=
+ .*pb2\.py,
+ .*pb2_grpc\.py,
[VARIABLES]
"py39",
"py310",
"py311",
+ "py312",
+ "py313",
]
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
[tool.isort]
profile = "black"
+py_version = 39
+follow_links = false
+
line_length = 80
src_paths = [
"examples/python/data_transmission",
"*pb2*.pyi",
"**/site-packages/**/*",
"tools/distrib/python/xds_protos/*",
+ "**/.venv-*",
]
single_line_exclusions = ["typing"]
force_single_line = true
#
-# This file is autogenerated by pip-compile with Python 3.8
+# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --allow-unsafe --output-file=requirements.bazel.lock requirements.bazel.txt
# via
# opentelemetry-api
# opentelemetry-semantic-conventions
-gevent==24.2.1
+gevent==25.9.1
# via -r requirements.bazel.txt
google-auth==2.38.0
# via -r requirements.bazel.txt
googleapis-common-protos==1.66.0
# via -r requirements.bazel.txt
-greenlet==3.1.1
+greenlet==3.2.4
# via gevent
hyperlink==21.0.0
# via twisted
# rsa
pyasn1-modules==0.4.1
# via google-auth
-pyyaml==6.0.2
+pyyaml==6.0.3
# via -r requirements.bazel.txt
requests==2.32.3
# via
# via incremental
twisted==24.11.0
# via -r requirements.bazel.txt
-typeguard==4.2.1
+typeguard==4.4.2
# via -r requirements.bazel.txt
typing-extensions==4.12.2
# via
# twisted
# The following packages are considered to be unsafe in a requirements file:
-setuptools==77.0.1 ; python_version > "3.8" # Manually added for python > 3.8, until Bazel RBE jobs support Python >= 3.9 (Tech debt: b/427881645)
-setuptools==75.3.2 ; python_version <= "3.8"
+setuptools==77.0.1
# via
# -r requirements.bazel.txt
# incremental
# Instructions for generation follow:
# Use the oldest supported version of Python
#
-# $ docker run -it --rm -v $(pwd):/grpc python:3.8 /bin/bash
+# $ docker run -it --rm -v $(pwd):/grpc python:3.9 /bin/bash
# # cd grpc
# # pip install pip-tools
# # pip-compile --allow-unsafe requirements.bazel.txt -o requirements.bazel.lock
# When installing a new package, sometimes it's desirable to avoid unnecessary
# package upgrades. In such case, consider the following flow instead.
#
-# $ python3.8 -m venv .venv-bazel
+# $ python3.9 -m venv .venv-bazel
# $ source .venv-bazel/bin/activate
# $ pip install pip-tools
-# $ pip install -r requirements.bazel.lock # make the change to version in requirements.bazel.txt after this
+# $ pip install -r requirements.bazel.lock
+#
+# Add the new package to requirements.bazel.txt
# $ pip-compile --no-upgrade --allow-unsafe requirements.bazel.txt -o requirements.bazel.lock
-# $ deactivate
+#
+# To update a single package, change its version spec requirements.bazel.txt
+# $ pip-compile --no-upgrade --allow-unsafe requirements.bazel.txt -o requirements.bazel.lock -P package_name
absl-py
certifi
chardet
-gevent
+gevent~=25.8
google-auth
googleapis-common-protos
idna
protobuf
pyyaml # for DNS test
requests
-setuptools>=77.0.1; python_version > "3.8"
-setuptools>=75.3.2; python_version <= "3.8"
-# Currently our CI uses Python < 3.8, hence <4.4.1 was added
-# TODO(asheshvidyut): remove the <4.4.1, when CI uses python >= 3.9
-typeguard~=4.2.0,<4.4.1
+setuptools>=77.0.1
+typeguard~=4.2
typing-extensions==4.12.2
twisted # for DNS test
urllib3
-#!/bin/bash
+#!/usr/bin/env bash
# Copyright 2015 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# See the License for the specific language governing permissions and
# limitations under the License.
-set -ex
+set -eux
ACTION="${1:-}"
[[ $ACTION == '' ]] || [[ $ACTION == '--diff' ]] || [[ $ACTION == '--check' ]]
'setup.py'
)
-VIRTUALENV=venv_black_code
-python3 -m virtualenv $VIRTUALENV
-source $VIRTUALENV/bin/activate
+VIRTUALENV=".venv-ci-black"
+python3 -m virtualenv "${VIRTUALENV}"
+source "${VIRTUALENV}/bin/activate"
+python -VV
-python3 -m pip install black==25.1.0
-python3 -m black --config=grpc-style-config.toml $ACTION "${DIRS[@]}"
+pip install black==25.1.0
+pip list
+
+exec black --config=grpc-style-config.toml $ACTION "${DIRS[@]}"
-#! /bin/bash -ex
+#!/usr/bin/env bash
# Copyright 2025 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# See the License for the specific language governing permissions and
# limitations under the License.
-VIRTUALENV=.venv_check_pytype
-python3.11 -m virtualenv $VIRTUALENV
-source $VIRTUALENV/bin/activate
+set -eux
+
+VIRTUALENV=".venv-ci-pytype"
+python3.11 -m virtualenv "${VIRTUALENV}"
+source "${VIRTUALENV}/bin/activate"
+python -VV
pip install pytype==2024.10.11
+pip list
+
pytype --output=~/.cache/pytype --config=grpc-style-config.toml
-#!/bin/bash
+#!/usr/bin/env bash
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# See the License for the specific language governing permissions and
# limitations under the License.
-set -ex
+set -eux
ACTION=${1:---overwrite-in-place}
[[ $ACTION == '--overwrite-in-place' ]] || [[ $ACTION == '--diff' ]]
'setup.py'
)
-VIRTUALENV=venv_isort_code
-python3 -m virtualenv $VIRTUALENV
-source $VIRTUALENV/bin/activate
+VIRTUALENV=".venv-ci-isort"
+python3 -m virtualenv "${VIRTUALENV}"
+source "${VIRTUALENV}/bin/activate"
+python -VV
-python3 -m pip install isort==5.9.2
-python3 -m isort $ACTION --settings-path=grpc-style-config.toml --dont-follow-links "${DIRS[@]}"
+pip install isort==6.0.1
+pip list
+
+isort $ACTION --settings-path=grpc-style-config.toml "${DIRS[@]}"
-#!/bin/bash
+#!/usr/bin/env bash
# Copyright 2017 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# See the License for the specific language governing permissions and
# limitations under the License.
-set -ex
-
-# NOTE(rbellevi): We ignore generated code.
-IGNORE_PATTERNS=--ignore-patterns='.*pb2\.py,.*pb2_grpc\.py'
+set -eux
# change to root directory
cd "$(dirname "$0")/../.."
'src/python/grpcio_tests/tests_gevent'
)
-VIRTUALENV=".venv-pylint"
-
-# When running locally, allow to reuse existing venv.
-if [[ ! -d "${VIRTUALENV}" ]]; then
- python3.11 -m virtualenv "${VIRTUALENV}"
-fi
-
+VIRTUALENV=".venv-ci-pylint"
+python3.11 -m virtualenv "${VIRTUALENV}"
source "${VIRTUALENV}/bin/activate"
-python3 --version
+python -VV
# TODO(https://github.com/grpc/grpc/issues/23394): Update Pylint.
-pip install --upgrade astroid==2.15.8 \
- pylint==2.17.7 \
- "isort~=5.11"
+pip install --upgrade astroid==2.15.8 pylint==2.17.7 "isort~=5.11"
+pip list
EXIT=0
for dir in "${DIRS[@]}"; do
- python3 -m pylint --rcfile=.pylintrc -rn "$dir" ${IGNORE_PATTERNS} || EXIT=1
+ pylint --rcfile=.pylintrc -rn "$dir" || EXIT=1
done
for dir in "${TEST_DIRS[@]}"; do
- python3 -m pylint --rcfile=.pylintrc-tests -rn "$dir" ${IGNORE_PATTERNS} || EXIT=1
+ pylint --rcfile=.pylintrc-tests -rn "$dir" || EXIT=1
done
-find examples/python \
- -iname "*.py" \
- -not -name "*_pb2.py" \
- -not -name "*_pb2_grpc.py" \
- | xargs python3 -m pylint --rcfile=.pylintrc-examples -rn ${IGNORE_PATTERNS}
+find examples/python -iname "*.py" -not -name "*_pb2*.py" \
+ | xargs pylint --rcfile=.pylintrc-examples -rn
exit $EXIT
-#!/bin/bash
+#!/usr/bin/env bash
# Copyright 2025 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# See the License for the specific language governing permissions and
# limitations under the License.
-set -ex
+set -eux
+
+ACTION="${1:-}"
+[[ $ACTION == '' ]] || [[ $ACTION == '--fix' ]]
# change to root directory
cd "$(dirname "$0")/../.."
examples/python
)
-VIRTUALENV=.venv-ruff
-python3 -m virtualenv $VIRTUALENV
-source $VIRTUALENV/bin/activate
-python3 --version
+VIRTUALENV=".venv-ci-ruff"
+python3 -m virtualenv "${VIRTUALENV}"
+source "${VIRTUALENV}/bin/activate"
+python -VV
pip install ruff==0.12.2
+pip list
-# Check if --fix flag is provided
-RUFF_COMMAND="ruff check"
-if [[ "$1" == "--fix" ]]; then
- RUFF_COMMAND="ruff check --fix"
-fi
-
-exec $RUFF_COMMAND "${DIRS[@]}"
+exec ruff check $ACTION "${DIRS[@]}"
if [[ -f /GRPC_IMAGE_NAME ]]; then
echo "gRPC custom VM image: $(cat /GRPC_IMAGE_NAME)"
fi
-echo -e "System: $(uname -a)\n"
+echo -e "System: $(uname -a)"
+echo -e "Python: $(python3 -VV)\n"
echo -e "-- OS --\n$(lsb_release -a 2>/dev/null)\n"
echo -e "-- CPU --\n$(lscpu)\n"
echo -e "-- Memory --\n$(lsmem --summary)\n$(free -h --si)\n"