-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-wheel.sh
executable file
·151 lines (140 loc) · 3.85 KB
/
check-wheel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
set -euo pipefail
wheelhouse="${1:-wheelhouse}"
ls -d "$wheelhouse" > /dev/null
savedir=$(pwd)
tempdir=$(mktemp -d)
workdir=$tempdir/wheel
trap 'rm -rf $tempdir' EXIT
for wheelfile in "$wheelhouse"/*.whl; do
cd "$savedir" && rm -rf "$workdir"
unzip -vv "$wheelfile"
unzip -qq "$wheelfile" -d "$workdir"
cd "$workdir"
whlname=$(basename "$wheelfile")
pkgname=${whlname%%-*}
mpiname=${pkgname}
data=$(ls -d "$pkgname"-*.data/data)
if test "$(uname)" = Linux; then
# shellcheck disable=SC2016
runpath='\$ORIGIN/../lib|\$ORIGIN'
soregex='\.so\..*'
runlibs='lib(mpi|c|m|dl|rt|pthread)'$soregex
runlibs=$runlibs'|(ld-linux-.*|ld64)'$soregex
libsdir=.libs
print-runpath() { patchelf --print-rpath "$1"; }
print-needed() { patchelf --print-needed "$1"; }
if test -f "$data"/lib/libucp.so; then
runlibs=$runlibs'|libuc(m|p|s|t)'$soregex
fi
fi
if test "$(uname)" = Darwin; then
runpath='@executable_path/../lib/|@loader_path/'
soregex='\..*\.dylib'
runlibs='lib(mpi|pmpi|System|objc)'$soregex
runlibs=$runlibs'|(Foundation|IOKit)\.framework'
libsdir=.dylibs
print-runpath() { otool -l "$1" | sed -n '/RPATH/{n;n;p;}'; }
print-needed() { otool -L "$1" | sed 1,1d; }
if test -f "$data"/lib/libucp.dylib; then
runlibs=$runlibs'|libuc(m|p|s|t)'$soregex
fi
fi
if test "$mpiname" = "mpich"; then
headers=(
"$data"/include/mpi.h
"$data"/include/mpio.h
)
scripts=(
"$data"/bin/mpicc
"$data"/bin/mpic++
"$data"/bin/mpicxx
)
wrappers=()
programs=(
"$data"/bin/mpichversion
"$data"/bin/mpivars
"$data"/bin/mpiexec
"$data"/bin/mpiexec.*
"$data"/bin/hydra_*
)
libraries=(
"$data"/lib/libmpi.*
)
if test -d "$data"/lib/ucx; then
libraries+=(
"$data"/lib/libuc[mpst]*.*
"$data"/lib/ucx/libuc*.*
)
fi
fi
if test "$mpiname" = "openmpi"; then
headers=(
"$data"/include/mpi.h
)
scripts=()
wrappers=(
"$data"/bin/mpicc
"$data"/bin/mpic++
"$data"/bin/mpicxx
"$data"/bin/mpiCC
"$data"/bin/mpirun
"$data"/bin/mpiexec
)
programs=(
"$data"/bin/*_info
"$data"/bin/*_wrapper
)
libraries=(
"$data"/lib/libmpi.*
"$data"/lib/libopen-*.*
)
runlibs+='|lib(z|util|event.*|hwloc)'$soregex
runlibs+='|lib(open-(pal|rte)|pmix|prrte)'$soregex
fi
check-binary() {
local dso=$1 out1="" out2=""
echo checking "$dso"...
test -f "$dso" || printf "ERROR: file not found\n"
out1="$(print-runpath "$dso" | grep -vE "$runpath" || true)"
test -z "$out1" || printf "ERROR: RUNPATH\n%s\n" "$out1"
out2="$(print-needed "$dso" | grep -vE "$runlibs" || true)"
test -z "$out2" || printf "ERROR: NEEDED\n%s\n" "$out2"
test -z "$out1" -a -z "$out2"
}
for header in "${headers[@]-}"; do
test -n "$header" || break
echo checking "$header"...
test -f "$header"
out=$(grep -E '^#include\s+"mpicxx\.h"' "$header" || true)
test -z "$out" || printf "ERROR: include\n%s\n" "$out"
test -z "$out"
done
for script in "${scripts[@]-}"; do
test -n "$script" || break
echo checking "$script"...
test -f "$script"
out=$(grep -E "/opt/$mpiname" "$script" || true)
test -z "$out" || printf "ERROR: prefix\n%s\n" "$out"
test -z "$out"
done
for bin in "${wrappers[@]-}"; do
test -n "$bin" || break
check-binary "$bin"
done
for bin in "${programs[@]-}"; do
test -n "$bin" || break
check-binary "$bin"
done
for lib in "${libraries[@]-}"; do
test -n "$lib" || break
check-binary "$lib"
done
if test -d "$pkgname$libsdir"; then
echo checking "$pkgname$libsdir"...
out=$(ls -A "$pkgname$libsdir")
test -z "$out" || printf "ERROR: library\n%s\n" "$out"
test -z "$out"
fi
echo success!
done