Skip to content

Commit 383e72b

Browse files
Detect missing cpuinfo package when running test-libs.sh and let the user know (#967)
Due to the fact that the package name is not the same as the module name (`py-cpuinfo` vs `cpuinfo`), the error that results from trying to run this script when `py-cpuinfo` is not installed can be confusing. Let's help users & developers by testing for the package and pointing them in the right direction. Also, slightly improve the clarity of the usage message text in this script. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent b560450 commit 383e72b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

dev_tools/test_libs.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,27 @@
1616
set -eo pipefail -o errtrace
1717

1818
declare -r usage="Usage: ${0##*/} [-h | --help | help] [bazel options ...]
19-
Run the programs in tests/, and on Linux, also build the programs in apps/.
19+
20+
Invokes Bazel to run the programs in tests/, and on Linux, also build the
21+
sample programs in apps/.
2022
2123
If the first option on the command line is -h, --help, or help, this help text
2224
will be printed and the program will exit. Any other options on the command
23-
line are passed directly to Bazel."
25+
line are passed directly to Bazel.
26+
27+
This script makes use of the Python package 'py-cpuinfo'."
2428

2529
# Exit early if the user requested help.
2630
if [[ "$1" == "-h" || "$1" == "--help" || "$1" == "help" ]]; then
2731
echo "$usage"
2832
exit 0
2933
fi
3034

35+
if ! python -m pip show -qq py-cpuinfo 2>/dev/null; then
36+
echo "Error: missing 'py-cpuinfo'. Please install dev-requirements.txt." >&2
37+
exit 1
38+
fi
39+
3140
# Look for AVX and SSE in the processor's feature flags.
3241
declare features=""
3342
declare filters=""

0 commit comments

Comments
 (0)