yapf: Add more detailed error message and TODO (flutter/engine#56458)

The yapf Python formatter is abandoned and only works with Python versions up to and including Python 3.11. upgraded, this will become more and more problematic. On some Linux distributions side-by-side python installations are unsupported, for example.

Issue: https://github.com/flutter/flutter/issues/158384

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
Chris Bracken
2024-11-08 12:11:23 -08:00
committed by GitHub
parent cdc18f9d61
commit cff2f440f9

View File

@@ -36,14 +36,22 @@ function follow_links() (
SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")") SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")")
SRC_DIR="$(cd "$SCRIPT_DIR/../.."; pwd -P)" SRC_DIR="$(cd "$SCRIPT_DIR/../.."; pwd -P)"
YAPF_DIR="$(cd "$SRC_DIR/flutter/third_party/yapf"; pwd -P)" YAPF_DIR="$(cd "$SRC_DIR/flutter/third_party/yapf"; pwd -P)"
# TODO: https://github.com/flutter/flutter/issues/158384
# Migrate to a supported Python formatter.
if command -v python3.10 &> /dev/null; then if command -v python3.10 &> /dev/null; then
PYTHON_EXEC="python3.10" PYTHON_EXEC="python3.10"
elif command -v python3.11 &> /dev/null; then
PYTHON_EXEC="python3.11"
else else
python3 -c " python3 -c "
import sys import sys
version = sys.version_info version = sys.version_info
if (version.major, version.minor) > (3, 11): if (version.major, version.minor) > (3, 11):
print(f'Error: python3 version {version.major}.{version.minor} is greater than 3.11.', file=sys.stderr) print(f'Error: The yapf Python formatter requires Python version 3.11 or '
f'earlier. The installed python3 version is '
f'{version.major}.{version.minor}.',
file=sys.stderr)
sys.exit(1) sys.exit(1)
else: else:
print(f'Using python3 version {version.major}.{version.minor}.') print(f'Using python3 version {version.major}.{version.minor}.')