Skip to content

Commit f6e8388

Browse files
committed
Check cpu features more portably in test_libs.sh
The previous commands to get cpu features on Windows failed on GitHub Windows-2022 runners. It seems the underlying commands used by the script changed. The new approach in this commit uses the Python `py-cpuinfo` package, which works on Windows and has the bonus of working on Mac and Linux too, allowing us to simply the test_libs.sh further.
1 parent b69aa08 commit f6e8388

2 files changed

Lines changed: 5 additions & 22 deletions

File tree

dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ black~=25.1.0
22
flynt~=1.0
33
pytest
44
pytest-xdist
5+
py-cpuinfo

dev_tools/test_libs.sh

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,12 @@ if [[ "$1" == "-h" || "$1" == "--help" || "$1" == "help" ]]; then
2828
exit 0
2929
fi
3030

31-
declare features=""
32-
shopt -s nocasematch
33-
# Note: can't use Bash $OSTYPE var here b/c the value is "linux-gnu" on Win 10.
34-
case "$(uname -s)" in
35-
darwin*)
36-
features=$(sysctl machdep.cpu.features)
37-
;;
38-
linux*)
39-
features=$(grep -m1 -i "^flags" /proc/cpuinfo)
40-
;;
41-
windows*|cygwin*|mingw32*|msys*|mingw*)
42-
features=$(wmic cpu get Caption,InstructionSet /value 2>/dev/null)
43-
;;
44-
*)
45-
echo "Unsupported OS: $(uname -s)"
46-
exit 1
47-
;;
48-
esac
49-
shopt -u nocasematch
50-
5131
# Unless we can tell this system supports AVX, we skip those tests.
32+
declare features=""
5233
declare filters=""
53-
[[ "$features" == *avx2* ]] || filters+=",-avx"
54-
[[ "$features" == *sse* ]] || filters+=",-sse"
34+
features="$(python -c 'import cpuinfo; print(" ".join(cpuinfo.get_cpu_info()["flags"]))')"
35+
[[ "$features" == *avx2* ]] && filters+=",-avx"
36+
[[ "$features" == *sse* ]] && filters+=",-sse"
5537
filters="${filters#,}"
5638

5739
declare -a build_filters=()

0 commit comments

Comments
 (0)