-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpydeps
executable file
·64 lines (58 loc) · 1.19 KB
/
pydeps
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
#!/usr/bin/env bash
#
# pydeps
# - audit a python build archive for extension module link deps
#
# desc
# - list modules with runtime link dependencies OTHER THAN LIBC
# - intended to assist in developing a Setup.local "*static*" section
# - uses a temporary directory to extract all .so files
# - removes tmpdir when done
#
# arg1
# - path to python build archive (tar.zst format)
#
# https://github.com/smemsh/utiladm/
# https://spdx.org/licenses/GPL-2.0
#
set -e
set -o pipefail
test -f ${1:?} && test -r $1
[[ `file -b --mime-type $1` =~ application/(x-){0,1}zstd ]]
abspath=$(readlink -f $1)
tmpdir=`mktemp -qd`
cd $tmpdir
tar \
-axf $abspath \
--wildcards '*.so' \
--transform 's,.*/,,' \
;
for file in *
do echo ${file%%.*}; ldd $file; echo; done \
| grep -vE \
-e linux-vdso \
-e ld-linux-x86 \
-e '\<libc\.so\.6\>' \
| awk '/^[[:alnum:]_]/ {
deps = ""
libline = $0
while (getline) {
if ($1 ~ /^lib/) {
deps = deps" "$1
continue
} else if (length(deps)) {
printf("%s:%s\n",
gensub("^.*/(.+).cpython.*$",
"\\1", 1, libline \
),
deps \
)
}
next
}
}' \
| sort \
| column -t
cd ..
rm -r "$tmpdir"