「python pip 从源码编译生成 pillow wheel」参考:https://pillow.readthedocs.io/en/stable/installation.html

我的平台是 ubuntu22.04

  1. 克隆代码

    git clone git@github.com:python-pillow/Pillow.git
    cd Pillow
    
  2. 创建虚拟环境并激活,安装编译 wheel 需要的 python 依赖

    python -m venv venv
    source venv/bin/activate
    pip install wheel setuptools auditwheel
  3. 安装编译 pillow 需要的外部库

    sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \
     libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \
     libharfbuzz-dev libfribidi-dev libxcb1-dev
  4. 编译 pillow 的 wheel

    python setup.py bdist_wheel

此时,会生成 dist/Pillow-10.1.0.dev0-cp310-cp310-linux_x86_64.whl

验证这个 wheel 是否可以正常安装

pip install dist/Pillow-10.1.0.dev0-cp310-cp310-linux_x86_64.whl

输出下面的命令,可以看到 pillow 安装成功了

─➤  pip show pillow                                                                                                 130 ↵
Name: Pillow
Version: 10.1.0.dev0
Summary: Python Imaging Library (Fork)
Home-page: https://python-pillow.org
Author: Jeffrey A. Clark (Alex)
Author-email: aclark@aclark.net
License: HPND
Location: /home/pon/code/me/github/Pillow/venv/lib/python3.10/site-packages
Requires: 
Required-by: 

可以正常导入包

╰─➤  python         
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
>>> Image
<module 'PIL.Image' from '/home/pon/code/me/github/Pillow/venv/lib/python3.10/site-packages/PIL/Image.py'>
>>> Image.open
<function open at 0x7f3168d91120>

好了,到此处,「python pip 从源码编译生成 pillow wheel」已经完成了。那为什么还会有 「并使用 auditwheel 包含预编译的二进制扩展」的需求呢?

原因你先可以参考:

跟着我下面的步骤走

─➤  pip show pillow
Name: Pillow
Version: 10.1.0.dev0
Summary: Python Imaging Library (Fork)
Home-page: https://python-pillow.org
Author: Jeffrey A. Clark (Alex)
Author-email: aclark@aclark.net
License: HPND
Location: /home/pon/code/me/github/Pillow/venv/lib/python3.10/site-packages
Requires: 
Required-by: 
(venv) ╭─pon@T4GPU ~/code/me/github/Pillow  ‹main*› 
╰─➤  cd /home/pon/code/me/github/Pillow/venv/lib/python3.10/site-packages/PIL
(venv) ╭─pon@T4GPU ~/code/me/github/Pillow/venv/lib/python3.10/site-packages/PIL  ‹main*› 
╰─➤  
                                                                                                                           

(venv) ╭─pon@T4GPU ~/code/me/github/Pillow/venv/lib/python3.10/site-packages/PIL  ‹main*› 
╰─➤  
(venv) ╭─pon@T4GPU ~/code/me/github/Pillow/venv/lib/python3.10/site-packages/PIL  ‹main*› 
╰─➤  
(venv) ╭─pon@T4GPU ~/code/me/github/Pillow/venv/lib/python3.10/site-packages/PIL  ‹main*› 
╰─➤  ll              
   inode Permissions Links Size Blocks User Group Date Modified Name
17587390 .rw-rw-r--      1 2.0k      8 pon  pon   30 Nov 15:39  __init__.py
17587393 .rw-rw-r--      1   41      8 pon  pon   30 Nov 15:39  __main__.py
17587414 drwxrwxr-x      2    -      - pon  pon   30 Nov 15:39  __pycache__
17587394 .rw-rw-r--      1 2.0k      8 pon  pon   30 Nov 15:39  _binary.py
17587395 .rw-rw-r--      1 1.9k      8 pon  pon   30 Nov 15:39  _deprecate.py
17587396 .rwxrwxr-x      1 1.9M   3720 pon  pon   30 Nov 15:39  _imaging.cpython-310-x86_64-linux-gnu.so
17587397 .rwxrwxr-x      1 108k    216 pon  pon   30 Nov 15:39  _imagingcms.cpython-310-x86_64-linux-gnu.so
17587398 .rwxrwxr-x      1 106k    208 pon  pon   30 Nov 15:39  _imagingft.cpython-310-x86_64-linux-gnu.so
17587399 .rwxrwxr-x      1  60k    120 pon  pon   30 Nov 15:39  _imagingmath.cpython-310-x86_64-linux-gnu.so
17587400 .rwxrwxr-x      1  34k     72 pon  pon   30 Nov 15:39  _imagingmorph.cpython-310-x86_64-linux-gnu.so
17587401 .rwxrwxr-x      1  40k     80 pon  pon   30 Nov 15:39  _imagingtk.cpython-310-x86_64-linux-gnu.so
17587402 .rw-rw-r--      1  503      8 pon  pon   30 Nov 15:39  _tkinter_finder.py
17587403 .rw-rw-r--      1  369      8 pon  pon   30 Nov 15:39  _util.py
17587404 .rw-rw-r--      1   56      8 pon  pon   30 Nov 15:39  _version.py
17587405 .rwxrwxr-x      1  81k    160 pon  pon   30 Nov 15:39  _webp.cpython-310-x86_64-linux-gnu.so
17587304 .rw-rw-r--      1 3.2k      8 pon  pon   30 Nov 15:39  BdfFontFile.py
17587305 .rw-rw-r--      1  15k     32 pon  pon   30 Nov 15:39  BlpImagePlugin.py
17587306 .rw-rw-r--      1  18k     40 pon  pon   30 Nov 15:39  BmpImagePlugin.py
17587307 .rw-rw-r--      1 1.6k      8 pon  pon   30 Nov 15:39  BufrStubImagePlugin.py
17587308 .rw-rw-r--      1 2.9k      8 pon  pon   30 Nov 15:39  ContainerIO.py
17587309 .rw-rw-r--      1 1.7k      8 pon  pon   30 Nov 15:39  CurImagePlugin.py
17587310 .rw-rw-r--      1 2.0k      8 pon  pon   30 Nov 15:39  DcxImagePlugin.py
17587311 .rw-rw-r--      1 9.4k     24 pon  pon   30 Nov 15:39  DdsImagePlugin.py
17587312 .rw-rw-r--      1  15k     32 pon  pon   30 Nov 15:39  EpsImagePlugin.py
17587313 .rw-rw-r--      1 9.7k     24 pon  pon   30 Nov 15:39  ExifTags.py
17587406 .rw-rw-r--      1 9.6k     24 pon  pon   30 Nov 15:39  features.py
17587314 .rw-rw-r--      1 2.1k      8 pon  pon   30 Nov 15:39  FitsImagePlugin.py
17587315 .rw-rw-r--      1 4.4k     16 pon  pon   30 Nov 15:39  FliImagePlugin.py
17587316 .rw-rw-r--      1 2.8k      8 pon  pon   30 Nov 15:39  FontFile.py
17587317 .rw-rw-r--      1 7.0k     16 pon  pon   30 Nov 15:39  FpxImagePlugin.py
17587318 .rw-rw-r--      1 3.4k      8 pon  pon   30 Nov 15:39  FtexImagePlugin.py
17587319 .rw-rw-r--      1 2.9k      8 pon  pon   30 Nov 15:39  GbrImagePlugin.py
17587320 .rw-rw-r--      1 2.6k      8 pon  pon   30 Nov 15:39  GdImageFile.py
17587321 .rw-rw-r--      1  36k     72 pon  pon   30 Nov 15:39  GifImagePlugin.py
17587322 .rw-rw-r--      1 3.4k      8 pon  pon   30 Nov 15:39  GimpGradientFile.py
17587323 .rw-rw-r--      1 1.3k      8 pon  pon   30 Nov 15:39  GimpPaletteFile.py
17587324 .rw-rw-r--      1 1.6k      8 pon  pon   30 Nov 15:39  GribStubImagePlugin.py
17587325 .rw-rw-r--      1 1.6k      8 pon  pon   30 Nov 15:39  Hdf5StubImagePlugin.py
17587326 .rw-rw-r--      1  12k     24 pon  pon   30 Nov 15:39  IcnsImagePlugin.py
17587327 .rw-rw-r--      1  12k     24 pon  pon   30 Nov 15:39  IcoImagePlugin.py
17587329 .rw-rw-r--      1 134k    264 pon  pon   30 Nov 15:39  Image.py
17587330 .rw-rw-r--      1 7.0k     16 pon  pon   30 Nov 15:39  ImageChops.py
17587331 .rw-rw-r--      1  37k     80 pon  pon   30 Nov 15:39  ImageCms.py
17587332 .rw-rw-r--      1 9.1k     24 pon  pon   30 Nov 15:39  ImageColor.py
17587333 .rw-rw-r--      1  36k     72 pon  pon   30 Nov 15:39  ImageDraw.py
17587334 .rw-rw-r--      1 5.5k     16 pon  pon   30 Nov 15:39  ImageDraw2.py
17587335 .rw-rw-r--      1 3.2k      8 pon  pon   30 Nov 15:39  ImageEnhance.py
17587336 .rw-rw-r--      1  24k     48 pon  pon   30 Nov 15:39  ImageFile.py
17587337 .rw-rw-r--      1  17k     40 pon  pon   30 Nov 15:39  ImageFilter.py
17587338 .rw-rw-r--      1  42k     88 pon  pon   30 Nov 15:39  ImageFont.py
17587339 .rw-rw-r--      1 5.6k     16 pon  pon   30 Nov 15:39  ImageGrab.py
17587340 .rw-rw-r--      1 7.4k     16 pon  pon   30 Nov 15:39  ImageMath.py
17587341 .rw-rw-r--      1 2.9k      8 pon  pon   30 Nov 15:39  ImageMode.py
17587342 .rw-rw-r--      1 8.0k     16 pon  pon   30 Nov 15:39  ImageMorph.py
17587343 .rw-rw-r--      1  21k     48 pon  pon   30 Nov 15:39  ImageOps.py
17587344 .rw-rw-r--      1 7.9k     16 pon  pon   30 Nov 15:39  ImagePalette.py
17587345 .rw-rw-r--      1  336      8 pon  pon   30 Nov 15:39  ImagePath.py
17587346 .rw-rw-r--      1 6.4k     16 pon  pon   30 Nov 15:39  ImageQt.py
17587347 .rw-rw-r--      1 1.9k      8 pon  pon   30 Nov 15:39  ImageSequence.py
17587348 .rw-rw-r--      1 8.3k     24 pon  pon   30 Nov 15:39  ImageShow.py
17587349 .rw-rw-r--      1 3.9k      8 pon  pon   30 Nov 15:39  ImageStat.py
17587350 .rw-rw-r--      1 8.5k     24 pon  pon   30 Nov 15:39  ImageTk.py
17587351 .rw-rw-r--      1 2.9k      8 pon  pon   30 Nov 15:39  ImageTransform.py
17587352 .rw-rw-r--      1 7.2k     16 pon  pon   30 Nov 15:39  ImageWin.py
17587328 .rw-rw-r--      1  11k     24 pon  pon   30 Nov 15:39  ImImagePlugin.py
17587353 .rw-rw-r--      1 2.6k      8 pon  pon   30 Nov 15:39  ImtImagePlugin.py
17587354 .rw-rw-r--      1 5.8k     16 pon  pon   30 Nov 15:39  IptcImagePlugin.py
17587355 .rw-rw-r--      1  12k     24 pon  pon   30 Nov 15:39  Jpeg2KImagePlugin.py
17587356 .rw-rw-r--      1  29k     64 pon  pon   30 Nov 15:39  JpegImagePlugin.py
17587357 .rw-rw-r--      1  12k     32 pon  pon   30 Nov 15:39  JpegPresets.py
17587358 .rw-rw-r--      1 1.8k      8 pon  pon   30 Nov 15:39  McIdasImagePlugin.py
17587359 .rw-rw-r--      1 2.5k      8 pon  pon   30 Nov 15:39  MicImagePlugin.py
17587360 .rw-rw-r--      1 1.8k      8 pon  pon   30 Nov 15:39  MpegImagePlugin.py
17587361 .rw-rw-r--      1 6.3k     16 pon  pon   30 Nov 15:39  MpoImagePlugin.py
17587362 .rw-rw-r--      1 5.6k     16 pon  pon   30 Nov 15:39  MspImagePlugin.py
17587364 .rw-rw-r--      1 1.1k      8 pon  pon   30 Nov 15:39  PaletteFile.py
17587365 .rw-rw-r--      1 9.1k     24 pon  pon   30 Nov 15:39  PalmImagePlugin.py
17587366 .rw-rw-r--      1 1.5k      8 pon  pon   30 Nov 15:39  PcdImagePlugin.py
17587367 .rw-rw-r--      1 6.8k     16 pon  pon   30 Nov 15:39  PcfFontFile.py
17587368 .rw-rw-r--      1 6.0k     16 pon  pon   30 Nov 15:39  PcxImagePlugin.py
17587369 .rw-rw-r--      1 8.8k     24 pon  pon   30 Nov 15:39  PdfImagePlugin.py
17587370 .rw-rw-r--      1  34k     72 pon  pon   30 Nov 15:39  PdfParser.py
17587371 .rw-rw-r--      1 1.7k      8 pon  pon   30 Nov 15:39  PixarImagePlugin.py
17587372 .rw-rw-r--      1  46k     96 pon  pon   30 Nov 15:39  PngImagePlugin.py
17587373 .rw-rw-r--      1  11k     24 pon  pon   30 Nov 15:39  PpmImagePlugin.py
17587374 .rw-rw-r--      1 7.5k     16 pon  pon   30 Nov 15:39  PsdImagePlugin.py
17587363 .rw-rw-r--      1 6.5k     16 pon  pon   30 Nov 15:39  PSDraw.py
17587375 .rw-rw-r--      1 9.9k     24 pon  pon   30 Nov 15:39  PyAccess.py
17587376 .rw-rw-r--      1 3.6k      8 pon  pon   30 Nov 15:39  QoiImagePlugin.py
17587377 .rw-rw-r--      1 6.2k     16 pon  pon   30 Nov 15:39  SgiImagePlugin.py
17587378 .rw-rw-r--      1 9.5k     24 pon  pon   30 Nov 15:39  SpiderImagePlugin.py
17587379 .rw-rw-r--      1 4.4k     16 pon  pon   30 Nov 15:39  SunImagePlugin.py
17587380 .rw-rw-r--      1 1.5k      8 pon  pon   30 Nov 15:39  TarIO.py
17587381 .rw-rw-r--      1 6.6k     16 pon  pon   30 Nov 15:39  TgaImagePlugin.py
17587382 .rw-rw-r--      1  77k    152 pon  pon   30 Nov 15:39  TiffImagePlugin.py
17587383 .rw-rw-r--      1  17k     40 pon  pon   30 Nov 15:39  TiffTags.py
17587384 .rw-rw-r--      1 5.5k     16 pon  pon   30 Nov 15:39  WalImageFile.py
17587385 .rw-rw-r--      1  11k     24 pon  pon   30 Nov 15:39  WebPImagePlugin.py
17587386 .rw-rw-r--      1 4.7k     16 pon  pon   30 Nov 15:39  WmfImagePlugin.py
17587388 .rw-rw-r--      1 2.5k      8 pon  pon   30 Nov 15:39  XbmImagePlugin.py
17587389 .rw-rw-r--      1 3.2k      8 pon  pon   30 Nov 15:39  XpmImagePlugin.py
17587387 .rw-rw-r--      1 2.0k      8 pon  pon   30 Nov 15:39  XVThumbImagePlugin.py

使用 ldd 命令查看 pillow 库依赖的外部库信息

╰─➤  ldd _imaging.cpython-310-x86_64-linux-gnu.so                                                                    127 ↵
        linux-vdso.so.1 (0x00007ffd8afbc000)
        libtiff.so.5 => /lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f8fe6994000)
        libjpeg.so.8 => /lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f8fe6913000)
        libopenjp2.so.7 => /lib/x86_64-linux-gnu/libopenjp2.so.7 (0x00007f8fe68bb000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f8fe689f000)
        libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f8fe6875000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8fe664b000)
        libwebp.so.7 => /lib/x86_64-linux-gnu/libwebp.so.7 (0x00007f8fe65de000)
        libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007f8fe650f000)
        liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f8fe64e4000)
        libjbig.so.0 => /lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f8fe64d3000)
        libdeflate.so.0 => /lib/x86_64-linux-gnu/libdeflate.so.0 (0x00007f8fe64af000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8fe63c6000)
        libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f8fe63c0000)
        libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f8fe63b8000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f8fe6a9a000)
        libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f8fe63a0000)
        libmd.so.0 => /lib/x86_64-linux-gnu/libmd.so.0 (0x00007f8fe6393000)

可以看到 libtiff.so.5 指向的位置是 /lib/x86_64-linux-gnu/libtiff.so.5 ; libjpeg.so.8 指向的是 /lib/x86_64-linux-gnu/libjpeg.so.8

这会导致一个问题,就是你在一台新机器上执行 pip install dist/Pillow-10.1.0.dev0-cp310-cp310-linux_x86_64.whl ,你会发现下面的报错

>>> from PIL import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/PIL/Image.py", line 82, in <module>
    from . import _imaging as core
ImportError: libtiff.so.5: cannot open shared object file: No such file or directory

所以我们需要 「并使用 auditwheel 包含预编译的二进制扩展」把外部库也一起打包进 wheel 里面,而不是继续引用系统库

那么怎么实现「并使用 auditwheel 包含预编译的二进制扩展」?查看下面的回答就好了 https://segmentfault.com/q/1010000044210279

我也在实现一遍,看我操作

auditwheel 的用法参考:编译 pyav 成 wheel 并使用 auditwheel 固化动态链接库
auditwheel repair dist/*.whl --plat=manylinux_2_35_x86_64

完整日志

╰─➤  auditwheel repair dist/*.whl --plat=manylinux_2_35_x86_64
INFO:auditwheel.main_repair:Repairing Pillow-10.1.0.dev0-cp310-cp310-linux_x86_64.whl
INFO:auditwheel.wheeltools:Previous filename tags: linux_x86_64
INFO:auditwheel.wheeltools:New filename tags: manylinux_2_35_x86_64
INFO:auditwheel.wheeltools:Previous WHEEL info tags: cp310-cp310-linux_x86_64
INFO:auditwheel.wheeltools:New WHEEL info tags: cp310-cp310-manylinux_2_35_x86_64
INFO:auditwheel.main_repair:
Fixed-up wheel written to /home/pon/code/me/github/Pillow/wheelhouse/Pillow-10.1.0.dev0-cp310-cp310-manylinux_2_35_x86_64.whl

此时会生成一个 wheelhouse/Pillow-10.1.0.dev0-cp310-cp310-manylinux_2_35_x86_64.whl

然后我们在新的环境验证一遍,安装这个 wheelhouse/Pillow-10.1.0.dev0-cp310-cp310-manylinux_2_35_x86_64.whl ,看看还会不会出现 ImportError: libtiff.so.5: cannot open shared object file: No such file or directory

  1. 运行一个干净的容器

    docker run --rm -it --name python-bookworm python:3.10-bookworm bash
  2. 宿主机新开一个终端,把 wheel 文件拷贝到容器里面

    docker cp wheelhouse/Pillow-10.1.0.dev0-cp310-cp310-manylinux_2_35_x86_64.whl python-bookworm:/root
  3. 在容器里面安装 wheel

    pip install /root/Pillow-10.1.0.dev0-cp310-cp310-manylinux_2_35_x86_64.whl
  4. 在 python shell 里面验证是否可以正常导包了

    root@496b3e7e8606:/# python
    Python 3.10.13 (main, Nov 29 2023, 05:20:19) [GCC 12.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from PIL import Image
    >>> 

    可以看到,已经可以正常导入 pillow 了

  5. 使用 ldd 查看引用的外部库

    root@496b3e7e8606:/# ldd /usr/local/lib/python3.10/site-packages/PIL/_imaging.cpython-310-x86_64-linux-gnu.so
         linux-vdso.so.1 (0x00007ffdd4d70000)
         libtiff-4f732bf2.so.5.7.0 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libtiff-4f732bf2.so.5.7.0 (0x00007feeeb189000)
         libjpeg-2cfbcf67.so.8.2.2 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libjpeg-2cfbcf67.so.8.2.2 (0x00007feeeb107000)
         libopenjp2-2ca9ae0b.so.2.4.0 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libopenjp2-2ca9ae0b.so.2.4.0 (0x00007feeeb0ae000)
         libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007feeeb089000)
         libxcb-aabc4890.so.1.1.0 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libxcb-aabc4890.so.1.1.0 (0x00007feeeb052000)
         libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007feeeae71000)
         libwebp-2cff2529.so.7.1.3 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libwebp-2cff2529.so.7.1.3 (0x00007feeeae03000)
         libzstd-5df4f4df.so.1.4.8 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libzstd-5df4f4df.so.1.4.8 (0x00007feeead2f000)
         liblzma-493cb401.so.5.2.5 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/liblzma-493cb401.so.5.2.5 (0x00007feeead03000)
         libjbig-32ed19ff.so.0 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libjbig-32ed19ff.so.0 (0x00007feeeacef000)
         libdeflate-dce39e00.so.0 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libdeflate-dce39e00.so.0 (0x00007feeeacca000)
         libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007feeeabeb000)
         libXau-98343a83.so.6.0.0 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libXau-98343a83.so.6.0.0 (0x00007feeeabe4000)
         libXdmcp-1dc3ff12.so.6.0.0 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libXdmcp-1dc3ff12.so.6.0.0 (0x00007feeeabda000)
         /lib64/ld-linux-x86-64.so.2 (0x00007feeeb28e000)
         libbsd-e4ad21c2.so.0.11.5 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libbsd-e4ad21c2.so.0.11.5 (0x00007feeeabbe000)
         libmd-bb376813.so.0.0.5 => /usr/local/lib/python3.10/site-packages/PIL/../Pillow.libs/libmd-bb376813.so.0.0.5 (0x00007feeeabb0000)

可以看到,auditwheel 已经帮我们修改了外部库库了

ok 此时大功告成


我们也可以对比 auditwheel 前后的 wheel 包的体积大小观测这一点

auditwheel 前

╰─➤  ll dist/Pillow-10.1.0.dev0-cp310-cp310-linux_x86_64.whl             
   inode Permissions Links Size Blocks User Group Date Modified Name
17587392 .rw-rw-r--      1 1.2M   2448 pon  pon   30 Nov 15:36  dist/Pillow-10.1.0.dev0-cp310-cp310-linux_x86_64.whl

auditwheel 后

╰─➤  ll wheelhouse/Pillow-10.1.0.dev0-cp310-cp310-manylinux_2_35_x86_64.whl
   inode Permissions Links Size Blocks User Group Date Modified Name
18232582 .rw-rw-r--      1 3.5M   6744 pon  pon    1 Dec 15:17  wheelhouse/Pillow-10.1.0.dev0-cp310-cp310-manylinux_2_35_x86_64.whl

可以看到,auditwheel 前是 1.2M,auditwheel 后是 3.5MB


universe_king
3.4k 声望680 粉丝