mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-01 09:10:03 +00:00
Use Python to check the version of pylint
This reduces dependencies, doesn't require maintainers to know awk, and makes the version parsing more robust. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
6d82a7ef9f
commit
bdde5d002c
@ -28,19 +28,24 @@ else
|
|||||||
PYTHON=python
|
PYTHON=python
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
check_version () {
|
||||||
|
$PYTHON - "$2" <<EOF
|
||||||
|
import packaging.version
|
||||||
|
import sys
|
||||||
|
import $1 as package
|
||||||
|
actual = package.__version__
|
||||||
|
wanted = sys.argv[1]
|
||||||
|
if packaging.version.parse(actual) < packaging.version.parse(wanted):
|
||||||
|
sys.stderr.write("$1: version %s is too old (want %s)\n" % (actual, wanted))
|
||||||
|
exit(1)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
can_pylint () {
|
can_pylint () {
|
||||||
# Pylint 1.5.2 from Ubuntu 16.04 is too old:
|
# Pylint 1.5.2 from Ubuntu 16.04 is too old:
|
||||||
# E: 34, 0: Unable to import 'mbedtls_dev' (import-error)
|
# E: 34, 0: Unable to import 'mbedtls_dev' (import-error)
|
||||||
# Pylint 1.8.3 from Ubuntu 18.04 passed on the first commit containing this line.
|
# Pylint 1.8.3 from Ubuntu 18.04 passed on the first commit containing this line.
|
||||||
$PYTHON -m pylint 2>/dev/null --version | awk '
|
check_version pylint 1.8.3
|
||||||
BEGIN {status = 1}
|
|
||||||
/^(pylint[0-9]*|__main__\.py) +[0-9]+\.[0-9]+/ {
|
|
||||||
split($2, version, /[^0-9]+/);
|
|
||||||
status = !(version[1] >= 2 || (version[1] == 1 && version[2] >= 8));
|
|
||||||
exit; # executes the END block
|
|
||||||
}
|
|
||||||
END {exit status}
|
|
||||||
'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
can_mypy () {
|
can_mypy () {
|
||||||
|
Loading…
Reference in New Issue
Block a user