python+cython+pyav 如何构建一个包含第三方动态链接库的 wheel 包?

python+cython+pyav 如何构建一个包含第三方动态链接库的 wheel 包?

使用 pyav,想要自己打包一个 wheel,但是发现了一些问题 https://github.com/PyAV-Org/PyAV

如果我直接通过 pip install av 安装 pyav,在 pyav 的路径下,会有一个 av.libs 存在 pyav 依赖的第三方动态链接库

先查看 av 的安装路径

╰─➤  pip show av  

Name: av

Version: 10.0.0

Summary: Pythonic bindings for FFmpeg's libraries.

Home-page: https://github.com/PyAV-Org/PyAV

Author: Mike Boers

Author-email: pyav@mikeboers.com

License: BSD

Location: /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages

Requires:

Required-by:

可以看到和 av 相关的有三个包

╰─➤  ll /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages | grep av

drwxrwxr-x 11 pon pon 4.0K Nov 30 2022 av

drwxrwxr-x 3 pon pon 4.0K Nov 30 2022 av-10.0.0.dist-info

drwxrwxr-x 2 pon pon 4.0K Nov 30 2022 av.libs

在这个 av.libs 下面有一堆动态链接库

─➤  ll av.libs                                                                                            

total 67M

drwxrwxr-x 2 pon pon 4.0K Nov 30 2022 .

drwxrwxr-x 182 pon pon 12K Feb 27 2023 ..

-rwxrwxr-x 1 pon pon 7.0M Nov 30 2022 libaom-e9efed4a.so.3.2.0

-rwxrwxr-x 1 pon pon 260K Nov 30 2022 libass-8499ab98.so.9.1.3

-rwxrwxr-x 1 pon pon 14M Nov 30 2022 libavcodec-8a88085f.so.59.37.100

-rwxrwxr-x 1 pon pon 120K Nov 30 2022 libavdevice-ed40abdd.so.59.7.100

-rwxrwxr-x 1 pon pon 4.3M Nov 30 2022 libavfilter-2d5314ec.so.8.44.100

-rwxrwxr-x 1 pon pon 2.6M Nov 30 2022 libavformat-20d4e1d0.so.59.27.100

-rwxrwxr-x 1 pon pon 825K Nov 30 2022 libavutil-1701948d.so.57.28.100

-rwxrwxr-x 1 pon pon 327K Nov 30 2022 libbluray-69850b93.so.2.1.2

-rwxrwxr-x 1 pon pon 1.6M Nov 30 2022 libdav1d-df61568f.so.5.1.1

-rwxrwxr-x 1 pon pon 330K Nov 30 2022 libfontconfig-99ba2620.so.1.12.0

-rwxrwxr-x 1 pon pon 701K Nov 30 2022 libfreetype-19bd6cfb.so.6.17.1

-rwxrwxr-x 1 pon pon 126K Nov 30 2022 libfribidi-baef595b.so.0.4.0

-rwxrwxr-x 1 pon pon 484K Nov 30 2022 libgmp-dbb9f291.so.10.4.1

-rwxrwxr-x 1 pon pon 2.3M Nov 30 2022 libgnutls-58994bd7.so.30.31.0

-rwxrwxr-x 1 pon pon 1.1M Nov 30 2022 libharfbuzz-d40f381a.so.0.40100.0

-rw-rw-r-- 1 pon pon 318K Nov 30 2022 libhogweed-5d799758.so.6.4

-rwxrwxr-x 1 pon pon 160K Nov 30 2022 liblzma-f3a5963b.so.5.2.5

-rwxrwxr-x 1 pon pon 408K Nov 30 2022 libmp3lame-3ecc6556.so.0.0.0

-rw-rw-r-- 1 pon pon 296K Nov 30 2022 libnettle-cb75a9d6.so.8.4

-rwxrwxr-x 1 pon pon 43K Nov 30 2022 libogg-bbd52b06.so.0.8.5

-rwxrwxr-x 1 pon pon 169K Nov 30 2022 libopencore-amrnb-393dbae2.so.0.0.3

-rwxrwxr-x 1 pon pon 81K Nov 30 2022 libopencore-amrwb-9db94aa9.so.0.0.3

-rwxrwxr-x 1 pon pon 521K Nov 30 2022 libopenjp2-0d101c52.so.2.4.0

-rwxrwxr-x 1 pon pon 363K Nov 30 2022 libopus-70bda348.so.0.8.0

-rwxrwxr-x 1 pon pon 192K Nov 30 2022 libpng16-1f529098.so.16.37.0

-rwxrwxr-x 1 pon pon 130K Nov 30 2022 libpostproc-9d3ac700.so.56.6.100

-rwxrwxr-x 1 pon pon 106K Nov 30 2022 libspeex-b6a53f7a.so.1.5.1

-rwxrwxr-x 1 pon pon 130K Nov 30 2022 libswresample-b868a3ce.so.4.7.100

-rwxrwxr-x 1 pon pon 606K Nov 30 2022 libswscale-a6aee226.so.6.7.100

-rwxrwxr-x 1 pon pon 122K Nov 30 2022 libtheoradec-f01ee89e.so.1.1.4

-rwxrwxr-x 1 pon pon 257K Nov 30 2022 libtheoraenc-276df146.so.1.1.2

-rwxrwxr-x 1 pon pon 141K Nov 30 2022 libtwolame-72d74ef7.so.0.0.0

-rwxrwxr-x 1 pon pon 1.6M Nov 30 2022 libunistring-aeeab030.so.2.1.0

-rwxrwxr-x 1 pon pon 21K Nov 30 2022 libuuid-f64cda11.so.1.3.0

-rwxrwxr-x 1 pon pon 701K Nov 30 2022 libvorbisenc-0d9d5bdf.so.2.0.12

-rwxrwxr-x 1 pon pon 239K Nov 30 2022 libvorbis-f4a9a6fd.so.0.4.9

-rwxrwxr-x 1 pon pon 2.1M Nov 30 2022 libvpx-c1705a7a.so.7.0.0

-rwxrwxr-x 1 pon pon 2.2M Nov 30 2022 libx264-2881b7ff.so.164

-rwxrwxr-x 1 pon pon 19M Nov 30 2022 libx265-d8690e8d.so.199

-rwxrwxr-x 1 pon pon 17K Nov 30 2022 libXau-00ec42fe.so.6.0.0

-rwxrwxr-x 1 pon pon 206K Nov 30 2022 libxcb-65da195c.so.1.1.0

-rwxrwxr-x 1 pon pon 26K Nov 30 2022 libxcb-shape-25c2b258.so.0.0.0

-rwxrwxr-x 1 pon pon 25K Nov 30 2022 libxcb-shm-7a199f70.so.0.0.0

-rwxrwxr-x 1 pon pon 53K Nov 30 2022 libxcb-xfixes-9be3ba6f.so.0.0.0

-rwxrwxr-x 1 pon pon 1.6M Nov 30 2022 libxml2-47a785fa.so.2.9.13

-rw-rw-r-- 1 pon pon 653K Nov 30 2022 libxvidcore-d29bca61.so.4.3

说明 pyav 是把这些第三方依赖一起打包到了 wheel 文件里面,安装一次性通过 pip 安装了

当我进入 /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av

查看其中任何一个 so 文件的 ldd 信息

_core.cpython-310-x86_64-linux-gnu.so 举例, 可以看到 ldd 信息确实是指向了刚刚的 av.libs 文件夹

─➤  ldd _core.cpython-310-x86_64-linux-gnu.so                      

linux-vdso.so.1 (0x00007ffc21d9a000)

libavformat-20d4e1d0.so.59.27.100 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libavformat-20d4e1d0.so.59.27.100 (0x00007f324ed90000)

libavcodec-8a88085f.so.59.37.100 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libavcodec-8a88085f.so.59.37.100 (0x00007f324da73000)

libavdevice-ed40abdd.so.59.7.100 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libavdevice-ed40abdd.so.59.7.100 (0x00007f324da54000)

libavutil-1701948d.so.57.28.100 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libavutil-1701948d.so.57.28.100 (0x00007f324d876000)

libavfilter-2d5314ec.so.8.44.100 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libavfilter-2d5314ec.so.8.44.100 (0x00007f324d425000)

libswscale-a6aee226.so.6.7.100 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libswscale-a6aee226.so.6.7.100 (0x00007f324d382000)

libswresample-b868a3ce.so.4.7.100 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libswresample-b868a3ce.so.4.7.100 (0x00007f324d360000)

libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f324d331000)

libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f324d13f000)

libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f324cff0000)

libxml2-47a785fa.so.2.9.13 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libxml2-47a785fa.so.2.9.13 (0x00007f324ce64000)

libbluray-69850b93.so.2.1.2 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libbluray-69850b93.so.2.1.2 (0x00007f324ce0f000)

libgmp-dbb9f291.so.10.4.1 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libgmp-dbb9f291.so.10.4.1 (0x00007f324cd96000)

libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f324cd7a000)

libgnutls-58994bd7.so.30.31.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libgnutls-58994bd7.so.30.31.0 (0x00007f324cb41000)

libvpx-c1705a7a.so.7.0.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libvpx-c1705a7a.so.7.0.0 (0x00007f324c92c000)

liblzma-f3a5963b.so.5.2.5 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/liblzma-f3a5963b.so.5.2.5 (0x00007f324c901000)

libdav1d-df61568f.so.5.1.1 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libdav1d-df61568f.so.5.1.1 (0x00007f324c73b000)

libopencore-amrwb-9db94aa9.so.0.0.3 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libopencore-amrwb-9db94aa9.so.0.0.3 (0x00007f324c725000)

libaom-e9efed4a.so.3.2.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libaom-e9efed4a.so.3.2.0 (0x00007f324bfe5000)

libmp3lame-3ecc6556.so.0.0.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libmp3lame-3ecc6556.so.0.0.0 (0x00007f324bf51000)

libopencore-amrnb-393dbae2.so.0.0.3 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libopencore-amrnb-393dbae2.so.0.0.3 (0x00007f324bf23000)

libopenjp2-0d101c52.so.2.4.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libopenjp2-0d101c52.so.2.4.0 (0x00007f324be9f000)

libopus-70bda348.so.0.8.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libopus-70bda348.so.0.8.0 (0x00007f324be43000)

libspeex-b6a53f7a.so.1.5.1 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libspeex-b6a53f7a.so.1.5.1 (0x00007f324be27000)

libtheoraenc-276df146.so.1.1.2 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libtheoraenc-276df146.so.1.1.2 (0x00007f324bde5000)

libtheoradec-f01ee89e.so.1.1.4 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libtheoradec-f01ee89e.so.1.1.4 (0x00007f324bdc3000)

libtwolame-72d74ef7.so.0.0.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libtwolame-72d74ef7.so.0.0.0 (0x00007f324bd9a000)

libvorbis-f4a9a6fd.so.0.4.9 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libvorbis-f4a9a6fd.so.0.4.9 (0x00007f324bd5d000)

libvorbisenc-0d9d5bdf.so.2.0.12 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libvorbisenc-0d9d5bdf.so.2.0.12 (0x00007f324bcac000)

libx264-2881b7ff.so.164 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libx264-2881b7ff.so.164 (0x00007f324b989000)

libx265-d8690e8d.so.199 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libx265-d8690e8d.so.199 (0x00007f324a6fd000)

libxvidcore-d29bca61.so.4.3 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libxvidcore-d29bca61.so.4.3 (0x00007f324a5ef000)

libxcb-65da195c.so.1.1.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libxcb-65da195c.so.1.1.0 (0x00007f324a3bc000)

libxcb-shm-7a199f70.so.0.0.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libxcb-shm-7a199f70.so.0.0.0 (0x00007f324a1b5000)

libxcb-shape-25c2b258.so.0.0.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libxcb-shape-25c2b258.so.0.0.0 (0x00007f3249fae000)

libxcb-xfixes-9be3ba6f.so.0.0.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libxcb-xfixes-9be3ba6f.so.0.0.0 (0x00007f3249d9e000)

libpostproc-9d3ac700.so.56.6.100 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libpostproc-9d3ac700.so.56.6.100 (0x00007f3249d7c000)

libass-8499ab98.so.9.1.3 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libass-8499ab98.so.9.1.3 (0x00007f3249d3a000)

libfontconfig-99ba2620.so.1.12.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libfontconfig-99ba2620.so.1.12.0 (0x00007f3249ce6000)

libfreetype-19bd6cfb.so.6.17.1 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libfreetype-19bd6cfb.so.6.17.1 (0x00007f3249c35000)

/lib64/ld-linux-x86-64.so.2 (0x00007f324f03a000)

libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3249c2d000)

libunistring-aeeab030.so.2.1.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libunistring-aeeab030.so.2.1.0 (0x00007f3249aa6000)

libnettle-cb75a9d6.so.8.4 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libnettle-cb75a9d6.so.8.4 (0x00007f3249a5b000)

libhogweed-5d799758.so.6.4 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libhogweed-5d799758.so.6.4 (0x00007f3249a0a000)

libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f3249828000)

libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f324980b000)

libogg-bbd52b06.so.0.8.5 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libogg-bbd52b06.so.0.8.5 (0x00007f32497ff000)

librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f32497f5000)

libXau-00ec42fe.so.6.0.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libXau-00ec42fe.so.6.0.0 (0x00007f32495f0000)

libfribidi-baef595b.so.0.4.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libfribidi-baef595b.so.0.4.0 (0x00007f32495cd000)

libharfbuzz-d40f381a.so.0.40100.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libharfbuzz-d40f381a.so.0.40100.0 (0x00007f32494b9000)

libuuid-f64cda11.so.1.3.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libuuid-f64cda11.so.1.3.0 (0x00007f32492b3000)

libpng16-1f529098.so.16.37.0 => /home/pon/.local/share/virtualenvs/svddb_sdk-qAt4tE2E/lib/python3.10/site-packages/av/./../av.libs/libpng16-1f529098.so.16.37.0 (0x00007f3249282000)


但是当我想生成一个含有各种第三方动态链接库的 wheel 文件的时候,我不知道该怎么办了

我按照 pyav 的 readme.md 打包出来的 wheel 里面没有这些动态链接库,而是通过相对路径引用的

过程如下:

bash

git clone git@github.com:PyAV-Org/PyAV

cd PyAV

source scripts/activate.sh

# Either install the testing dependencies:

pip install --upgrade -r tests/requirements.txt

# or have it all, including FFmpeg, built/installed for you:

./scripts/build-deps

# Build PyAV.

make

https://github.com/PyAV-Org/PyAV/blob/main/README.md

打包成 wheel

python setup.py sdist bdist_wheel

然后新找了一个虚拟环境去安装这个包

─➤  pip install /home/pon/code/me/github/PyAV/dist/av-10.0.0-cp38-cp38-linux_x86_64.whl

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple

Processing /home/pon/code/me/github/PyAV/dist/av-10.0.0-cp38-cp38-linux_x86_64.whl

Installing collected packages: av

Successfully installed av-10.0.0

安装好了之后,看了一下是否有 av.libs 文件夹,发现没有

╰─➤  ll /home/pon/.local/share/virtualenvs/ideaboom-KZ0_GR-a/lib/python3.8/site-packages | grep av

drwxrwxr-x 11 pon pon 4.0K Sep 12 09:34 av

drwxrwxr-x 3 pon pon 4.0K Sep 12 09:34 av-10.0.0.dist-info


不过到是不影响使用

因为指向的动态链接库,指到 /lib/x86_64-linux-gnu/ 去了

(ideaboom) ╭─pon@admini ~/.local/share/virtualenvs/ideaboom-KZ0_GR-a/lib/python3.8/site-packages/av  

╰─➤ ldd _core.cpython-38-x86_64-linux-gnu.so

linux-vdso.so.1 (0x00007ffe2a5ac000)

libavformat.so.58 => /lib/x86_64-linux-gnu/libavformat.so.58 (0x00007fbb8c7ed000)

libavcodec.so.58 => /lib/x86_64-linux-gnu/libavcodec.so.58 (0x00007fbb8b22c000)

libavdevice.so.58 => /lib/x86_64-linux-gnu/libavdevice.so.58 (0x00007fbb8b1f8000)

libavutil.so.56 => /lib/x86_64-linux-gnu/libavutil.so.56 (0x00007fbb8b0cf000)

libavfilter.so.7 => /lib/x86_64-linux-gnu/libavfilter.so.7 (0x00007fbb8ad4e000)

libswscale.so.5 => /lib/x86_64-linux-gnu/libswscale.so.5 (0x00007fbb8acb7000)

libswresample.so.3 => /lib/x86_64-linux-gnu/libswresample.so.3 (0x00007fbb8ac93000)

libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbb8aaa1000)

libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbb8a952000)

libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007fbb8a798000)

libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007fbb8a785000)

libgme.so.0 => /lib/x86_64-linux-gnu/libgme.so.0 (0x00007fbb8a738000)

libopenmpt.so.0 => /lib/x86_64-linux-gnu/libopenmpt.so.0 (0x00007fbb8a549000)

libchromaprint.so.1 => /lib/x86_64-linux-gnu/libchromaprint.so.1 (0x00007fbb8a533000)

libbluray.so.2 => /lib/x86_64-linux-gnu/libbluray.so.2 (0x00007fbb8a4e2000)

libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fbb8a4c6000)

libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007fbb8a2f0000)

libssh-gcrypt.so.4 => /lib/x86_64-linux-gnu/libssh-gcrypt.so.4 (0x00007fbb8a264000)

libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbb8a25c000)

libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbb8a239000)

libvpx.so.6 => /lib/x86_64-linux-gnu/libvpx.so.6 (0x00007fbb8a001000)

libwebpmux.so.3 => /lib/x86_64-linux-gnu/libwebpmux.so.3 (0x00007fbb89ff5000)

libwebp.so.6 => /lib/x86_64-linux-gnu/libwebp.so.6 (0x00007fbb89f8b000)

liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fbb89f62000)

librsvg-2.so.2 => /lib/x86_64-linux-gnu/librsvg-2.so.2 (0x00007fbb89643000)

libgobject-2.0.so.0 => /lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007fbb895e3000)

libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fbb894b9000)

libcairo.so.2 => /lib/x86_64-linux-gnu/libcairo.so.2 (0x00007fbb89396000)

libzvbi.so.0 => /lib/x86_64-linux-gnu/libzvbi.so.0 (0x00007fbb89307000)

libsnappy.so.1 => /lib/x86_64-linux-gnu/libsnappy.so.1 (0x00007fbb892fc000)

libaom.so.0 => /lib/x86_64-linux-gnu/libaom.so.0 (0x00007fbb88e5c000)

libcodec2.so.0.9 => /lib/x86_64-linux-gnu/libcodec2.so.0.9 (0x00007fbb88078000)

libgsm.so.1 => /lib/x86_64-linux-gnu/libgsm.so.1 (0x00007fbb88069000)

libmp3lame.so.0 => /lib/x86_64-linux-gnu/libmp3lame.so.0 (0x00007fbb87ff1000)

libopenjp2.so.7 => /lib/x86_64-linux-gnu/libopenjp2.so.7 (0x00007fbb87f9b000)

libopus.so.0 => /lib/x86_64-linux-gnu/libopus.so.0 (0x00007fbb87f3c000)

libshine.so.3 => /lib/x86_64-linux-gnu/libshine.so.3 (0x00007fbb87d2f000)

libspeex.so.1 => /lib/x86_64-linux-gnu/libspeex.so.1 (0x00007fbb87d11000)

libtheoraenc.so.1 => /lib/x86_64-linux-gnu/libtheoraenc.so.1 (0x00007fbb87cd4000)

libtheoradec.so.1 => /lib/x86_64-linux-gnu/libtheoradec.so.1 (0x00007fbb87cb4000)

libtwolame.so.0 => /lib/x86_64-linux-gnu/libtwolame.so.0 (0x00007fbb87c8e000)

libvorbis.so.0 => /lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007fbb87c60000)

libvorbisenc.so.2 => /lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007fbb87bb3000)

libwavpack.so.1 => /lib/x86_64-linux-gnu/libwavpack.so.1 (0x00007fbb87b87000)

libx264.so.155 => /lib/x86_64-linux-gnu/libx264.so.155 (0x00007fbb878c9000)

libx265.so.179 => /lib/x86_64-linux-gnu/libx265.so.179 (0x00007fbb8695b000)

libxvidcore.so.4 => /lib/x86_64-linux-gnu/libxvidcore.so.4 (0x00007fbb86848000)

libva.so.2 => /lib/x86_64-linux-gnu/libva.so.2 (0x00007fbb8681f000)

libraw1394.so.11 => /lib/x86_64-linux-gnu/libraw1394.so.11 (0x00007fbb8660e000)

libavc1394.so.0 => /lib/x86_64-linux-gnu/libavc1394.so.0 (0x00007fbb86409000)

librom1394.so.0 => /lib/x86_64-linux-gnu/librom1394.so.0 (0x00007fbb86204000)

libiec61883.so.0 => /lib/x86_64-linux-gnu/libiec61883.so.0 (0x00007fbb861f6000)

libjack.so.0 => /lib/x86_64-linux-gnu/libjack.so.0 (0x00007fbb861aa000)

libdrm.so.2 => /lib/x86_64-linux-gnu/libdrm.so.2 (0x00007fbb86192000)

libopenal.so.1 => /lib/x86_64-linux-gnu/libopenal.so.1 (0x00007fbb860aa000)

libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fbb86080000)

libxcb-shm.so.0 => /lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007fbb8607b000)

libxcb-shape.so.0 => /lib/x86_64-linux-gnu/libxcb-shape.so.0 (0x00007fbb86076000)

libxcb-xfixes.so.0 => /lib/x86_64-linux-gnu/libxcb-xfixes.so.0 (0x00007fbb8606c000)

libcdio_paranoia.so.2 => /lib/x86_64-linux-gnu/libcdio_paranoia.so.2 (0x00007fbb86060000)

libcdio_cdda.so.2 => /lib/x86_64-linux-gnu/libcdio_cdda.so.2 (0x00007fbb86056000)

libdc1394.so.22 => /lib/x86_64-linux-gnu/libdc1394.so.22 (0x00007fbb85fde000)

libasound.so.2 => /lib/x86_64-linux-gnu/libasound.so.2 (0x00007fbb85ee3000)

libcaca.so.0 => /lib/x86_64-linux-gnu/libcaca.so.0 (0x00007fbb85e17000)

libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007fbb85d8f000)

libpulse.so.0 => /lib/x86_64-linux-gnu/libpulse.so.0 (0x00007fbb85d38000)

libSDL2-2.0.so.0 => /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 (0x00007fbb85be3000)

libsndio.so.7.0 => /lib/x86_64-linux-gnu/libsndio.so.7.0 (0x00007fbb85bd2000)

libXv.so.1 => /lib/x86_64-linux-gnu/libXv.so.1 (0x00007fbb859cd000)

libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007fbb85890000)

libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007fbb8587b000)

libva-drm.so.2 => /lib/x86_64-linux-gnu/libva-drm.so.2 (0x00007fbb85874000)

libva-x11.so.2 => /lib/x86_64-linux-gnu/libva-x11.so.2 (0x00007fbb8586c000)

libvdpau.so.1 => /lib/x86_64-linux-gnu/libvdpau.so.1 (0x00007fbb85866000)

libOpenCL.so.1 => /lib/x86_64-linux-gnu/libOpenCL.so.1 (0x00007fbb8565b000)

libpostproc.so.55 => /lib/x86_64-linux-gnu/libpostproc.so.55 (0x00007fbb85639000)

libbs2b.so.0 => /lib/x86_64-linux-gnu/libbs2b.so.0 (0x00007fbb85630000)

liblilv-0.so.0 => /lib/x86_64-linux-gnu/liblilv-0.so.0 (0x00007fbb85615000)

librubberband.so.2 => /lib/x86_64-linux-gnu/librubberband.so.2 (0x00007fbb855d8000)

libmysofa.so.1 => /lib/x86_64-linux-gnu/libmysofa.so.1 (0x00007fbb855c7000)

libflite_cmu_us_awb.so.1 => /lib/x86_64-linux-gnu/libflite_cmu_us_awb.so.1 (0x00007fbb851d0000)

libflite_cmu_us_kal.so.1 => /lib/x86_64-linux-gnu/libflite_cmu_us_kal.so.1 (0x00007fbb8506a000)

libflite_cmu_us_kal16.so.1 => /lib/x86_64-linux-gnu/libflite_cmu_us_kal16.so.1 (0x00007fbb84c8e000)

libflite_cmu_us_rms.so.1 => /lib/x86_64-linux-gnu/libflite_cmu_us_rms.so.1 (0x00007fbb847f3000)

libflite_cmu_us_slt.so.1 => /lib/x86_64-linux-gnu/libflite_cmu_us_slt.so.1 (0x00007fbb843fb000)

libflite.so.1 => /lib/x86_64-linux-gnu/libflite.so.1 (0x00007fbb843c2000)

libfribidi.so.0 => /lib/x86_64-linux-gnu/libfribidi.so.0 (0x00007fbb843a5000)

libass.so.9 => /lib/x86_64-linux-gnu/libass.so.9 (0x00007fbb84172000)

libvidstab.so.1.1 => /lib/x86_64-linux-gnu/libvidstab.so.1.1 (0x00007fbb8415c000)

libzmq.so.5 => /lib/x86_64-linux-gnu/libzmq.so.5 (0x00007fbb840b6000)

libfontconfig.so.1 => /lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fbb8406f000)

libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fbb83fb0000)

libsoxr.so.0 => /lib/x86_64-linux-gnu/libsoxr.so.0 (0x00007fbb83f45000)

/lib64/ld-linux-x86-64.so.2 (0x00007fbb8ca83000)

libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007fbb83d5d000)

libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fbb83b7b000)

libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fbb83b60000)

libmpg123.so.0 => /lib/x86_64-linux-gnu/libmpg123.so.0 (0x00007fbb83b00000)

libvorbisfile.so.3 => /lib/x86_64-linux-gnu/libvorbisfile.so.3 (0x00007fbb83af5000)

libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007fbb839bd000)

libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007fbb8399c000)

libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007fbb8381a000)

libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007fbb83804000)

libnettle.so.7 => /lib/x86_64-linux-gnu/libnettle.so.7 (0x00007fbb837ca000)

libhogweed.so.5 => /lib/x86_64-linux-gnu/libhogweed.so.5 (0x00007fbb83793000)

libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fbb8370d000)

libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007fbb835ef000)

libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007fbb835cc000)

libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007fbb8357f000)

libcairo-gobject.so.2 => /lib/x86_64-linux-gnu/libcairo-gobject.so.2 (0x00007fbb83573000)

libgdk_pixbuf-2.0.so.0 => /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007fbb83549000)

libgio-2.0.so.0 => /lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007fbb83368000)

libpangocairo-1.0.so.0 => /lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007fbb83356000)

libpango-1.0.so.0 => /lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007fbb83307000)

libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 (0x00007fbb832fb000)

libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fbb83288000)

libpixman-1.so.0 => /lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007fbb831df000)

libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007fbb831a7000)

libxcb-render.so.0 => /lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007fbb83198000)

libXrender.so.1 => /lib/x86_64-linux-gnu/libXrender.so.1 (0x00007fbb82f8e000)

libogg.so.0 => /lib/x86_64-linux-gnu/libogg.so.0 (0x00007fbb82f81000)

libnuma.so.1 => /lib/x86_64-linux-gnu/libnuma.so.1 (0x00007fbb82f72000)

librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fbb82f68000)

libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007fbb82f62000)

libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fbb82f5a000)

libcdio.so.18 => /lib/x86_64-linux-gnu/libcdio.so.18 (0x00007fbb82d32000)

libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007fbb82d14000)

libslang.so.2 => /lib/x86_64-linux-gnu/libslang.so.2 (0x00007fbb82a1d000)

libncursesw.so.6 => /lib/x86_64-linux-gnu/libncursesw.so.6 (0x00007fbb829e3000)

libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007fbb829b3000)

libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007fbb828fb000)

libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007fbb828c7000)

libpulsecommon-13.99.so => /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-13.99.so (0x00007fbb82843000)

libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007fbb827f2000)

libXcursor.so.1 => /lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007fbb827e5000)

libXinerama.so.1 => /lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007fbb827e0000)

libXi.so.6 => /lib/x86_64-linux-gnu/libXi.so.6 (0x00007fbb827ce000)

libXrandr.so.2 => /lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007fbb827bf000)

libXss.so.1 => /lib/x86_64-linux-gnu/libXss.so.1 (0x00007fbb827ba000)

libXxf86vm.so.1 => /lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007fbb827b3000)

libwayland-egl.so.1 => /lib/x86_64-linux-gnu/libwayland-egl.so.1 (0x00007fbb827ae000)

libwayland-client.so.0 => /lib/x86_64-linux-gnu/libwayland-client.so.0 (0x00007fbb8279d000)

libwayland-cursor.so.0 => /lib/x86_64-linux-gnu/libwayland-cursor.so.0 (0x00007fbb82792000)

libxkbcommon.so.0 => /lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007fbb82750000)

libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007fbb82734000)

libXfixes.so.3 => /lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007fbb8272c000)

libserd-0.so.0 => /lib/x86_64-linux-gnu/libserd-0.so.0 (0x00007fbb8270b000)

libsord-0.so.0 => /lib/x86_64-linux-gnu/libsord-0.so.0 (0x00007fbb826ff000)

libsratom-0.so.0 => /lib/x86_64-linux-gnu/libsratom-0.so.0 (0x00007fbb826f3000)

libsamplerate.so.0 => /lib/x86_64-linux-gnu/libsamplerate.so.0 (0x00007fbb82385000)

libfftw3.so.3 => /lib/x86_64-linux-gnu/libfftw3.so.3 (0x00007fbb8217f000)

libflite_usenglish.so.1 => /lib/x86_64-linux-gnu/libflite_usenglish.so.1 (0x00007fbb82154000)

libflite_cmulex.so.1 => /lib/x86_64-linux-gnu/libflite_cmulex.so.1 (0x00007fbb820bd000)

libharfbuzz.so.0 => /lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007fbb81fb9000)

libgomp.so.1 => /lib/x86_64-linux-gnu/libgomp.so.1 (0x00007fbb81f75000)

libsodium.so.23 => /lib/x86_64-linux-gnu/libsodium.so.23 (0x00007fbb81f1d000)

libpgm-5.2.so.0 => /lib/x86_64-linux-gnu/libpgm-5.2.so.0 (0x00007fbb81ece000)

libnorm.so.1 => /lib/x86_64-linux-gnu/libnorm.so.1 (0x00007fbb81d73000)

libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fbb81d45000)

libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fbb81d3c000)

libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007fbb80279000)

libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007fbb8019c000)

libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007fbb8016b000)

libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007fbb80164000)

libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007fbb80155000)

libgmodule-2.0.so.0 => /lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007fbb8014d000)

libmount.so.1 => /lib/x86_64-linux-gnu/libmount.so.1 (0x00007fbb800ed000)

libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fbb800c2000)

libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fbb800a6000)

libpangoft2-1.0.so.0 => /lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007fbb8008d000)

libthai.so.0 => /lib/x86_64-linux-gnu/libthai.so.0 (0x00007fbb80080000)

libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007fbb80053000)

libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007fbb7ffa4000)

libwrap.so.0 => /lib/x86_64-linux-gnu/libwrap.so.0 (0x00007fbb7ff98000)

libsndfile.so.1 => /lib/x86_64-linux-gnu/libsndfile.so.1 (0x00007fbb7ff1a000)

libasyncns.so.0 => /lib/x86_64-linux-gnu/libasyncns.so.0 (0x00007fbb7fd12000)

libapparmor.so.1 => /lib/x86_64-linux-gnu/libapparmor.so.1 (0x00007fbb7fcfd000)

libgraphite2.so.3 => /lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007fbb7fcd0000)

libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007fbb7fcc9000)

libblkid.so.1 => /lib/x86_64-linux-gnu/libblkid.so.1 (0x00007fbb7fc70000)

libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007fbb7fbdf000)

libdatrie.so.1 => /lib/x86_64-linux-gnu/libdatrie.so.1 (0x00007fbb7fbd5000)

liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007fbb7fbb4000)

libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007fbb7fb97000)

libFLAC.so.8 => /lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007fbb7fb57000)

但是我还是想把这些依赖的动态链接库整到 av.libs 路径中,要怎么搞?


然后我把这个 wheel 包,找了一个 docker 测试了一下

docker pull python:3.8-bookworm

docker run --rm -it -v ./dist:/code python:3.8

-bookworm bash

cd code

PS1="\[\e[1;32m\](base) \[\e[1;34m\]\u@\h:\[\e[0m\]\w# "

alias ll="ls -alh --color"

安装

(base) root@6588d6ebf9be:/code# ll

total 6.3M

drwxrwxr-x 2 1001 1001 4.0K Sep 12 09:22 .

drwxr-xr-x 1 root root 4.0K Sep 12 09:45 ..

-rw-rw-r-- 1 1001 1001 3.9M Sep 12 09:22 av-10.0.0-cp38-cp38-linux_x86_64.whl

-rw-rw-r-- 1 1001 1001 2.4M Sep 12 09:22 av-10.0.0.tar.gz

(base) root@6588d6ebf9be:/code# pip install ./av-10.0.0-cp38-cp38-linux_x86_64.whl

Processing ./av-10.0.0-cp38-cp38-linux_x86_64.whl

Installing collected packages: av

Successfully installed av-10.0.0

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.0.1 -> 23.2.1

[notice] To update, run: pip install --upgrade pip

看一下有没有 av.libs

(base) root@6588d6ebf9be:/code# pip show av

Name: av

Version: 10.0.0

Summary: Pythonic bindings for FFmpeg's libraries.

Home-page: https://github.com/PyAV-Org/PyAV

Author: Mike Boers

Author-email: pyav@mikeboers.com

License: BSD

Location: /usr/local/lib/python3.8/site-packages

Requires:

Required-by:

(base) root@6588d6ebf9be:/code# cd /usr/local/lib/python3.8/site-packages

(base) root@6588d6ebf9be:/usr/local/lib/python3.8/site-packages# ll

total 68K

drwxr-xr-x 1 root root 4.0K Sep 12 09:46 .

drwxr-xr-x 1 root root 4.0K Sep 7 13:41 ..

-rw-r--r-- 1 root root 119 Sep 7 13:41 README.txt

drwxr-xr-x 1 root root 4.0K Sep 12 09:46 _distutils_hack

drwxr-xr-x 11 root root 4.0K Sep 12 09:46 av

drwxr-xr-x 3 root root 4.0K Sep 12 09:46 av-10.0.0.dist-info

-rw-r--r-- 1 root root 152 Sep 7 13:41 distutils-precedence.pth

drwxr-xr-x 1 root root 4.0K Sep 12 09:46 pip

drwxr-xr-x 2 root root 4.0K Sep 7 13:41 pip-23.0.1.dist-info

drwxr-xr-x 5 root root 4.0K Sep 7 13:41 pkg_resources

drwxr-xr-x 6 root root 4.0K Sep 7 13:41 setuptools

drwxr-xr-x 2 root root 4.0K Sep 7 13:41 setuptools-57.5.0.dist-info

drwxr-xr-x 4 root root 4.0K Sep 7 13:41 wheel

drwxr-xr-x 2 root root 4.0K Sep 7 13:41 wheel-0.41.2.dist-info

没有 av.libs

查看 ldd _core.cpython-38-x86_64-linux-gnu.so

(base) root@6588d6ebf9be:/usr/local/lib/python3.8/site-packages# cd av

(base) root@6588d6ebf9be:/usr/local/lib/python3.8/site-packages/av#

(base) root@6588d6ebf9be:/usr/local/lib/python3.8/site-packages/av# ll

total 3.1M

drwxr-xr-x 11 root root 4.0K Sep 12 09:46 .

drwxr-xr-x 1 root root 4.0K Sep 12 09:46 ..

-rw-r--r-- 1 root root 0 Sep 12 09:46 __init__.pxd

-rw-r--r-- 1 root root 1.5K Sep 12 09:46 __init__.py

-rw-r--r-- 1 root root 1.2K Sep 12 09:46 __main__.py

drwxr-xr-x 2 root root 4.0K Sep 12 09:46 __pycache__

-rwxr-xr-x 1 root root 108K Sep 12 09:46 _core.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 23 Sep 12 09:46 about.py

drwxr-xr-x 3 root root 4.0K Sep 12 09:46 audio

-rwxr-xr-x 1 root root 139K Sep 12 09:46 buffer.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 134 Sep 12 09:46 buffer.pxd

-rwxr-xr-x 1 root root 104K Sep 12 09:46 bytesource.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 249 Sep 12 09:46 bytesource.pxd

drwxr-xr-x 3 root root 4.0K Sep 12 09:46 codec

drwxr-xr-x 3 root root 4.0K Sep 12 09:46 container

drwxr-xr-x 3 root root 4.0K Sep 12 09:46 data

-rw-r--r-- 1 root root 3.0K Sep 12 09:46 datasets.py

-rw-r--r-- 1 root root 2.3K Sep 12 09:46 deprecation.py

-rwxr-xr-x 1 root root 116K Sep 12 09:46 descriptor.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 527 Sep 12 09:46 descriptor.pxd

-rwxr-xr-x 1 root root 166K Sep 12 09:46 dictionary.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 182 Sep 12 09:46 dictionary.pxd

-rwxr-xr-x 1 root root 390K Sep 12 09:46 enum.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 66 Sep 12 09:46 enum.pxd

-rwxr-xr-x 1 root root 348K Sep 12 09:46 error.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 135 Sep 12 09:46 error.pxd

drwxr-xr-x 3 root root 4.0K Sep 12 09:46 filter

-rwxr-xr-x 1 root root 231K Sep 12 09:46 format.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 242 Sep 12 09:46 format.pxd

-rwxr-xr-x 1 root root 185K Sep 12 09:46 frame.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 453 Sep 12 09:46 frame.pxd

-rwxr-xr-x 1 root root 236K Sep 12 09:46 logging.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 24 Sep 12 09:46 logging.pxd

-rwxr-xr-x 1 root root 172K Sep 12 09:46 option.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 374 Sep 12 09:46 option.pxd

-rwxr-xr-x 1 root root 212K Sep 12 09:46 packet.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 447 Sep 12 09:46 packet.pxd

-rwxr-xr-x 1 root root 167K Sep 12 09:46 plane.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 196 Sep 12 09:46 plane.pxd

drwxr-xr-x 3 root root 4.0K Sep 12 09:46 sidedata

-rwxr-xr-x 1 root root 245K Sep 12 09:46 stream.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 676 Sep 12 09:46 stream.pxd

drwxr-xr-x 3 root root 4.0K Sep 12 09:46 subtitles

-rwxr-xr-x 1 root root 127K Sep 12 09:46 utils.cpython-38-x86_64-linux-gnu.so

-rw-r--r-- 1 root root 523 Sep 12 09:46 utils.pxd

drwxr-xr-x 3 root root 4.0K Sep 12 09:46 video

发现和 libav 相关的都是 not found

(base) root@6588d6ebf9be:/usr/local/lib/python3.8/site-packages/av# ldd _core.cpython-38-x86_64-linux-gnu.so

linux-vdso.so.1 (0x00007fff4f87d000)

libavformat.so.58 => not found

libavcodec.so.58 => not found

libavdevice.so.58 => not found

libavutil.so.56 => not found

libavfilter.so.7 => not found

libswscale.so.5 => not found

libswresample.so.3 => not found

libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa8ba68e000)

/lib64/ld-linux-x86-64.so.2 (0x00007fa8ba887000)

说明 pyav 依赖的 libav 等第三方库并没有被包含到 wheel 文件中


回答:

答案,需要使用 auditwheel、delocate 这样的工具

参考:

  • python 第三方包安装路径 site-packages 下面的以 .libs 结尾的路径是干嘛的?
  • How to build and distribute a Python/Cython package that depends on third party libFoo.so
  • how to build whl with numpy.libs

在 linux 存储这些第四方动态链接库,一般都是放在第三方包同级的 xxx.libs 文件夹下面

但是好像不也全是这样,比如 linux 下的 pandas 包,是放到 pandas/_libs/ 下面的

─➤  ll /home/pon/.local/share/virtualenvs/svddb_testing-xLs9aDku/lib/python3.10/site-packages/pandas/_libs/            

inode Permissions Links Size Blocks User Group Date Modified Name

17045879 .rw-rw-r-- 1 323 8 pon pon 12 2月 23:52 __init__.py

17045986 drwxrwxr-x 2 - - pon pon 12 2月 23:52 __pycache__

17045814 .rwxrwxr-x 1 2.0M 3992 pon pon 12 2月 23:52 algos.cpython-310-x86_64-linux-gnu.so

17045831 .rw-rw-r-- 1 440 8 pon pon 12 2月 23:52 algos.pxd

17045877 .rw-rw-r-- 1 15k 32 pon pon 12 2月 23:52 algos.pyi

17045810 .rw-rw-r-- 1 51k 104 pon pon 12 2月 23:52 algos.pyx

17045871 .rw-rw-r-- 1 2.3k 8 pon pon 12 2月 23:52 algos_common_helper.pxi.in

17045863 .rw-rw-r-- 1 6.1k 16 pon pon 12 2月 23:52 algos_take_helper.pxi.in

17045883 .rwxrwxr-x 1 93k 184 pon pon 12 2月 23:52 arrays.cpython-310-x86_64-linux-gnu.so

17045866 .rw-rw-r-- 1 233 8 pon pon 12 2月 23:52 arrays.pxd

17045811 .rw-rw-r-- 1 940 8 pon pon 12 2月 23:52 arrays.pyi

17045808 .rw-rw-r-- 1 5.9k 16 pon pon 12 2月 23:52 arrays.pyx

17045812 .rw-rw-r-- 1 510 8 pon pon 12 2月 23:52 dtypes.pxd

17045874 .rwxrwxr-x 1 2.0M 3952 pon pon 12 2月 23:52 groupby.cpython-310-x86_64-linux-gnu.so

17045829 .rw-rw-r-- 1 6.2k 16 pon pon 12 2月 23:52 groupby.pyi

17045882 .rw-rw-r-- 1 56k 112 pon pon 12 2月 23:52 groupby.pyx

17045826 .rwxrwxr-x 1 192k 376 pon pon 12 2月 23:52 hashing.cpython-310-x86_64-linux-gnu.so

17045841 .rw-rw-r-- 1 181 8 pon pon 12 2月 23:52 hashing.pyi

17045846 .rw-rw-r-- 1 4.8k 16 pon pon 12 2月 23:52 hashing.pyx

17045809 .rwxrwxr-x 1 1.6M 3104 pon pon 12 2月 23:52 hashtable.cpython-310-x86_64-linux-gnu.so

17045845 .rw-rw-r-- 1 3.2k 8 pon pon 12 2月 23:52 hashtable.pxd

17045844 .rw-rw-r-- 1 6.1k 16 pon pon 12 2月 23:52 hashtable.pyi

17045803 .rw-rw-r-- 1 4.6k 16 pon pon 12 2月 23:52 hashtable.pyx

17045857 .rw-rw-r-- 1 48k 96 pon pon 12 2月 23:52 hashtable_class_helper.pxi.in

17045825 .rw-rw-r-- 1 14k 32 pon pon 12 2月 23:52 hashtable_func_helper.pxi.in

17045828 .rwxrwxr-x 1 628k 1232 pon pon 12 2月 23:52 index.cpython-310-x86_64-linux-gnu.so

17045878 .rw-rw-r-- 1 3.1k 8 pon pon 12 2月 23:52 index.pyi

17045800 .rw-rw-r-- 1 34k 72 pon pon 12 2月 23:52 index.pyx

17045869 .rw-rw-r-- 1 2.0k 8 pon pon 12 2月 23:52 index_class_helper.pxi.in

17045870 .rwxrwxr-x 1 50k 104 pon pon 12 2月 23:52 indexing.cpython-310-x86_64-linux-gnu.so

17045819 .rw-rw-r-- 1 427 8 pon pon 12 2月 23:52 indexing.pyi

17045848 .rw-rw-r-- 1 778 8 pon pon 12 2月 23:52 indexing.pyx

17045833 .rwxrwxr-x 1 351k 688 pon pon 12 2月 23:52 internals.cpython-310-x86_64-linux-gnu.so

17045852 .rw-rw-r-- 1 2.4k 8 pon pon 12 2月 23:52 internals.pyi

17045858 .rw-rw-r-- 1 24k 48 pon pon 12 2月 23:52 internals.pyx

17045862 .rwxrwxr-x 1 1.4M 2672 pon pon 12 2月 23:52 interval.cpython-310-x86_64-linux-gnu.so

17045853 .rw-rw-r-- 1 5.4k 16 pon pon 12 2月 23:52 interval.pyi

17045820 .rw-rw-r-- 1 18k 40 pon pon 12 2月 23:52 interval.pyx

17045835 .rw-rw-r-- 1 15k 32 pon pon 12 2月 23:52 intervaltree.pxi.in

17045815 .rwxrwxr-x 1 2.5M 4904 pon pon 12 2月 23:52 join.cpython-310-x86_64-linux-gnu.so

17045807 .rw-rw-r-- 1 2.6k 8 pon pon 12 2月 23:52 join.pyi

17045851 .rw-rw-r-- 1 28k 56 pon pon 12 2月 23:52 join.pyx

17045832 .rwxrwxr-x 1 94k 184 pon pon 12 2月 23:52 json.cpython-310-x86_64-linux-gnu.so

17045842 .rw-rw-r-- 1 484 8 pon pon 12 2月 23:52 json.pyi

17045864 .rw-rw-r-- 1 3.8k 8 pon pon 12 2月 23:52 khash.pxd

17045813 .rw-rw-r-- 1 1.4k 8 pon pon 12 2月 23:52 khash_for_primitive_helper.pxi.in

17045801 .rwxrwxr-x 1 702k 1376 pon pon 12 2月 23:52 lib.cpython-310-x86_64-linux-gnu.so

17045849 .rw-rw-r-- 1 139 8 pon pon 12 2月 23:52 lib.pxd

17045837 .rw-rw-r-- 1 7.7k 16 pon pon 12 2月 23:52 lib.pyi

17045821 .rw-rw-r-- 1 92k 184 pon pon 12 2月 23:52 lib.pyx

17045805 .rwxrwxr-x 1 193k 384 pon pon 12 2月 23:52 missing.cpython-310-x86_64-linux-gnu.so

17045824 .rw-rw-r-- 1 408 8 pon pon 12 2月 23:52 missing.pxd

17045872 .rw-rw-r-- 1 675 8 pon pon 12 2月 23:52 missing.pyi

17045834 .rw-rw-r-- 1 14k 32 pon pon 12 2月 23:52 missing.pyx

17045868 .rwxrwxr-x 1 240k 472 pon pon 12 2月 23:52 ops.cpython-310-x86_64-linux-gnu.so

17045855 .rw-rw-r-- 1 1.3k 8 pon pon 12 2月 23:52 ops.pyi

17045850 .rw-rw-r-- 1 7.8k 16 pon pon 12 2月 23:52 ops.pyx

17045802 .rwxrwxr-x 1 61k 120 pon pon 12 2月 23:52 ops_dispatch.cpython-310-x86_64-linux-gnu.so

17045817 .rw-rw-r-- 1 124 8 pon pon 12 2月 23:52 ops_dispatch.pyi

17045839 .rw-rw-r-- 1 2.6k 8 pon pon 12 2月 23:52 ops_dispatch.pyx

17045822 .rwxrwxr-x 1 543k 1064 pon pon 12 2月 23:52 parsers.cpython-310-x86_64-linux-gnu.so

17045830 .rw-rw-r-- 1 2.2k 8 pon pon 12 2月 23:52 parsers.pyi

17045818 .rw-rw-r-- 1 70k 136 pon pon 12 2月 23:52 parsers.pyx

17045816 .rwxrwxr-x 1 63k 128 pon pon 12 2月 23:52 properties.cpython-310-x86_64-linux-gnu.so

17045806 .rw-rw-r-- 1 718 8 pon pon 12 2月 23:52 properties.pyi

17045881 .rw-rw-r-- 1 1.6k 8 pon pon 12 2月 23:52 properties.pyx

17045867 .rwxrwxr-x 1 32k 64 pon pon 12 2月 23:52 reduction.cpython-310-x86_64-linux-gnu.so

17045859 .rw-rw-r-- 1 214 8 pon pon 12 2月 23:52 reduction.pyi

17045838 .rw-rw-r-- 1 1.1k 8 pon pon 12 2月 23:52 reduction.pyx

17045827 .rwxrwxr-x 1 272k 536 pon pon 12 2月 23:52 reshape.cpython-310-x86_64-linux-gnu.so

17045873 .rw-rw-r-- 1 419 8 pon pon 12 2月 23:52 reshape.pyi

17045875 .rw-rw-r-- 1 3.4k 8 pon pon 12 2月 23:52 reshape.pyx

17045843 .rwxrwxr-x 1 870k 1704 pon pon 12 2月 23:52 sparse.cpython-310-x86_64-linux-gnu.so

17045856 .rw-rw-r-- 1 1.4k 8 pon pon 12 2月 23:52 sparse.pyi

17045884 .rw-rw-r-- 1 21k 48 pon pon 12 2月 23:52 sparse.pyx

17045804 .rw-rw-r-- 1 9.4k 24 pon pon 12 2月 23:52 sparse_op_helper.pxi.in

17045823 .rwxrwxr-x 1 93k 184 pon pon 12 2月 23:52 testing.cpython-310-x86_64-linux-gnu.so

17045861 .rw-rw-r-- 1 243 8 pon pon 12 2月 23:52 testing.pyi

17045847 .rw-rw-r-- 1 5.9k 16 pon pon 12 2月 23:52 testing.pyx

17045840 .rwxrwxr-x 1 331k 648 pon pon 12 2月 23:52 tslib.cpython-310-x86_64-linux-gnu.so

17045865 .rw-rw-r-- 1 766 8 pon pon 12 2月 23:52 tslib.pyi

17045854 .rw-rw-r-- 1 29k 64 pon pon 12 2月 23:52 tslib.pyx

17045885 drwxrwxr-x 3 - - pon pon 12 2月 23:52 tslibs

17045880 .rw-rw-r-- 1 272 8 pon pon 12 2月 23:52 util.pxd

17045948 drwxrwxr-x 3 - - pon pon 12 2月 23:52 window

17045836 .rwxrwxr-x 1 221k 432 pon pon 12 2月 23:52 writers.cpython-310-x86_64-linux-gnu.so

17045876 .rw-rw-r-- 1 543 8 pon pon 12 2月 23:52 writers.pyi

17045860 .rw-rw-r-- 1 4.5k 16 pon pon 12 2月 23:52 writers.pyx


好了,回答问题本身

我一开始是以 pyav 为切入点,但是 pyav 的 github 的仓库中,并没有提供任何线索来告诉我,这些 libav 相关的第四方依赖是怎么进入 wheel 文件的

但是我发现还有其他库也是这样实现的

(svddb_sdk) ╭─pon@amd5700g ~/.local/share/virtualenvs/svddb_sdk-oJGZEtXx/lib/python3.10/site-packages  

╰─➤ ll | grep .libs

17056431 drwxrwxr-x 2 - - pon pon 12 2月 23:56 av.libs

17060238 drwxrwxr-x 2 - - pon pon 12 2月 23:56 numpy.libs

17073792 drwxrwxr-x 2 - - pon pon 12 2月 23:56 opencv_python.libs

17060002 drwxrwxr-x 2 - - pon pon 12 2月 23:56 Pillow.libs

17182651 drwxrwxr-x 2 - - pon pon 12 2月 23:56 torchvision.libs

所以,可以从 numpy、Pillow 入手研究也可以

(未完待续)


所以,我们正常执行 pyav 的编译之后

git clone git@github.com:PyAV-Org/PyAV

cd PyAV

source scripts/activate.sh

# Either install the testing dependencies:

pip install --upgrade -r tests/requirements.txt

# or have it all, including FFmpeg, built/installed for you:

./scripts/build-deps

# Build PyAV.

make

在执行 python setup.py sdist bdist_wheel 生成对应的 wheel 文件,比如生成 dist/av-10.0.0-cp310-cp310-linux_x86_64.whl

然后使用 编译 pyav 成 wheel 并使用 auditwheel 固化动态链接库 里面的方式,使用 auditwheel repair 实现偷天换日

想验证替换是否成功了?执行 auditwheel show ./wheelhouse/av-10.0.0-cp310-cp310-manylinux_2_35_x86_64.whl 查看 wheel 文件信息即可

注意,此时的 wheel 名称和之前不一样了,会变成类似这样的格式: wheelhouse/av-10.0.0-cp310-cp310-manylinux_2_35_x86_64.whl

如果你想知道 manylinux_2_35 是什么含义,可以参考:pypa/manylinux

一些子问题:

  • 如何查看一个动态链接库中的依赖的其他动态链接库是绝对地址引用还是名字引用?参考: https://segmentfault.com/q/1010000044215818

打包的时候,需要注意宿主机的各种环境

可参考:

  • https://github.com/mayeut/pep600_compliance
  • https://github.com/pypa/auditwheel

以上是 python+cython+pyav 如何构建一个包含第三方动态链接库的 wheel 包? 的全部内容, 来源链接: utcz.com/p/939011.html

回到顶部