Skip to content

Commit aa6a2c7

Browse files
authored
Check cpu features more portably in test_libs.sh (#758)
1 parent 2251abc commit aa6a2c7

2 files changed

Lines changed: 3 additions & 20 deletions

File tree

dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ cmake~=3.31.0
33
flynt~=1.0
44
pytest
55
pytest-xdist
6+
py-cpuinfo

dev_tools/test_libs.sh

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,10 @@ 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=""
34+
features="$(python -c 'import cpuinfo; print(" ".join(cpuinfo.get_cpu_info().get("flags", [])))')"
5335
[[ "$features" == *avx2* ]] || filters+=",-avx"
5436
[[ "$features" == *sse* ]] || filters+=",-sse"
5537
filters="${filters#,}"

0 commit comments

Comments
 (0)