Skip to main content

跨发行版 Linux 轮子

项目描述

https://travis-ci.org/pypa/auditwheel.svg?branch=main https://badge.fury.io/py/auditwheel.svg https://pepy.tech/badge/auditwheel/month

审计和重新标记PEP 600 manylinux_x_yPEP 513 manylinux1PEP 571 manylinux2010PEP 599 manylinux2014 Linux 轮子。

概述

auditwheel是一个命令行工具,用于方便创建适用于 Linux 的 Python Wheel 包(包含预编译的二进制扩展),它与各种 Linux 发行版兼容,符合PEP 600 manylinux_x_yPEP 513 manylinux1PEP 571 manylinux2010PEP 599 manylinux2014平台标签。

auditwheel show:显示 wheel 依赖的外部共享库(超出manylinux策略中包含的库),并检查扩展模块是否使用了超出manylinux ABI 的版本化符号。

auditwheel repair:将这些外部共享库复制到轮子本身,并自动修改适当的RPATH条目,以便在运行时获取这些库。这实现了类似于库已被静态链接而无需更改构建系统的结果。建议打包者捆绑,如静态链接,可能涉及版权问题。

要求

  • 操作系统:Linux

  • 蟒蛇:3.6+

  • 补丁

仅支持使用基于ELF的链接的系统(这应该基本上是每个 Linux)。

一般来说,构建manylinux1轮子需要在CentOS5机器上运行,构建manylinux2010轮子需要在CentOS6机器上运行,构建manylinux2014轮子需要在CentOS7机器上运行,所以我们推荐使用预先构建的manylinux Docker镜像,例如

$ docker run -i -t -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /bin/bash

安装

auditwheel可以使用 pip 安装:

$ pip3 install auditwheel

例子

检查车轮:

$ auditwheel show cffi-1.5.0-cp35-cp35m-linux_x86_64.whl

cffi-1.5.0-cp35-cp35m-linux_x86_64.whl is consistent with the
following platform tag: "linux_x86_64".

The wheel references the following external versioned symbols in
system-provided shared libraries: GLIBC_2.3.

The following external shared libraries are required by the wheel:
{
    "libc.so.6": "/lib64/libc-2.5.so",
    "libffi.so.5": "/usr/lib64/libffi.so.5.0.6",
    "libpthread.so.0": "/lib64/libpthread-2.5.so"
}

In order to achieve the tag platform tag "manylinux1_x86_64" the
following shared library dependencies will need to be eliminated:

libffi.so.5

修理一个轮子。

$ auditwheel repair cffi-1.5.2-cp35-cp35m-linux_x86_64.whl
Repairing cffi-1.5.2-cp35-cp35m-linux_x86_64.whl
Grafting: /usr/lib64/libffi.so.5.0.6
Setting RPATH: _cffi_backend.cpython-35m-x86_64-linux-gnu.so to "$ORIGIN/.libs_cffi_backend"
Previous filename tags: linux_x86_64
New filename tags: manylinux1_x86_64
Previous WHEEL info tags: cp35-cp35m-linux_x86_64
New WHEEL info tags: cp35-cp35m-manylinux1_x86_64

Fixed-up wheel written to /wheelhouse/cffi-1.5.2-cp35-cp35m-manylinux1_x86_64.whl

限制

  1. auditwheel使用 Python 扩展模块中的DT_NEEDED 信息(如ldd)来确定它们依赖的系统库。使用ctypes / cffi(来自 Python)或 dlopen (来自 C/C++)在运行时动态加载库的代码不会以可以静态确定的方式包含此信息,因此将丢失通过这些机制加载的依赖项。

  2. 如果二进制文件是针对最新版本的libclibstdc++编译和链接的,我们就无法“修复”二进制文件。这些库(和其他一些库)使用符号版本控制来实现向后兼容性。一般来说,这意味着针对旧版本glibc编译的代码将在具有较新版本 glibc的系统上运行良好,但在新系统上编译的代码不会/可能不会在旧系统上运行。

    因此,要编译广泛兼容的二进制文件,最好在旧的 Linux 发行版上进行构建,例如 manylinux Docker 映像。

测试

可以使用tox运行测试,这将自动安装测试依赖项。

一些集成测试还需要运行且可访问的 Docker 守护程序。如果您的系统上尚不可用,这些测试将提取一些 docker 图像,但不会更新现有图像。要手动更新这些图像,请运行:

docker pull python:3.6-slim
docker pull quay.io/pypa/manylinux1_x86_64
docker pull quay.io/pypa/manylinux2010_x86_64
docker pull quay.io/pypa/manylinux2014_x86_64
docker pull quay.io/pypa/manylinux_2_24_x86_64

您也可以使用docker rmi删除这些图像。

行为守则

auditwheel项目的代码库、问题跟踪器、聊天室和邮件列表中进行交互的每个人都应遵守 PSF 行为准则

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

auditwheel-5.1.2.tar.gz (551.1 kB 查看哈希

已上传 source

内置分布

auditwheel-5.1.2-py3-none-any.whl (53.0 kB 查看哈希

已上传 py3