跳转到主要内容

针对Pyodide的auditwheel-like工具

项目描述

auditwheel-emscripten

PyPI Latest Release Test Status

针对Emscripten平台的目标wheels的auditwheel-like工具

$ pip install auditwheel-emscripten

这是什么?

auditwheel-emscripten是一个小工具,用于方便创建针对Emscripten的Python wheel包。auditwheel-emscripten最初是为Pyodide创建的,但它可以用于任何其他使用Emscripten针对Python-in-the-browser的项目。

  • pyodide auditwheel show:显示wheel依赖的外部共享库。
  • pyodide auditwheel repair:将这些外部共享库复制到wheel本身。

用法(命令行界面)

 Usage: pyodide auditwheel [OPTIONS] COMMAND [ARGS]...

 Auditwheel-like tool for emscripten wheels and shared libraries.

╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                                                                                         │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ copy      [Deprecated] Copy shared libraries to the wheel directory. Works same as repair. Use repair instead.          │
│ exports   Show exports of a wheel or a shared library file.                                                                         │
│ imports   Show imports of a wheel or a shared library file.                                                                         │
│ repair    Repair a wheel file: copy shared libraries to the wheel directory.   │
│ show      Show shared library dependencies of a wheel or a shared library file.                                                     │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
# wget https://cdn.jsdelivr.net.cn/pyodide/v0.21.3/full/Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl
$ pyodide auditwheel show Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl

The following external shared libraries are required:
{   'shapely/speedups/_speedups.cpython-310-wasm32-emscripten.so': ['libgeos_c.so'],
│   'shapely/vectorized/_vectorized.cpython-310-wasm32-emscripten.so': ['libgeos_c.so']
}
$ pyodide auditwheel repair --libdir <directory which contains libgeos_c.so> Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl

Repaired wheel has following external shared libraries:
{   'Shapely.libs/libgeos.so.3.10.3': [],
│   'Shapely.libs/libgeos_c.so': ['libgeos.so.3.10.3'],
│   'shapely/speedups/_speedups.cpython-310-wasm32-emscripten.so': ['libgeos_c.so'],
│   'shapely/vectorized/_vectorized.cpython-310-wasm32-emscripten.so': ['libgeos_c.so']
}

用法(API)

列出wheel文件的共享库依赖项

from auditwheel_emscripten import show
libs = show("Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl")
print(libs)
# {'shapely/vectorized/_vectorized.cpython-310-wasm32-emscripten.so': ['libgeos_c.so'], 'shapely/speedups/_speedups.cpython-310-wasm32-emscripten.so': ['libgeos_c.so']}

将共享库复制到wheel

from auditwheel_emscripten import repair, show
repaired_wheel = repair(
    "Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl",
    libdir="/path/where/shared/libraries/are/located",
    outdir="/path/to/output/directory",
)
libs = show(repaired_wheel)
print(libs)
# {'Shapely.libs/libgeos.so.3.10.3': [], 'Shapely.libs/libgeos_c.so': ['libgeos.so.3.10.3'], 'shapely/speedups/_speedups.cpython-310-wasm32-emscripten.so': ['libgeos_c.so'], 'shapely/vectorized/_vectorized.cpython-310-wasm32-emscripten.so': ['libgeos_c.so']}

实现细节/限制

Emscripten中的动态链接

动态链接不在WebAssembly规范中,但Emscripten有自己的动态链接支持,这是构建针对Emscripten平台的目标Python wheel所需的。

此工具基于

auditwheel与auditwheel-emscripten的比较

auditwheel 是一个工具,它帮助修复和修改 Python 轮子(预编译的包),使其与广泛的 Linux 发行版兼容。它是通过将外部共享库复制到轮子中,并修复 ELF 二进制文件的 RPATH(一个用于在运行时定位共享库的文件路径)来实现的,以便 Linux 操作系统可以在程序运行时找到库。

auditwheel-emscripten 是 auditwheel 的一个变体,专门设计用于与 Emscripten 生成的 WebAssembly(WASM)模块一起使用。它不对轮子进行审计,因为 Emscripten 不保证版本之间的兼容性。相反,它仅简单地将所需的库复制到轮子中,而不修改模块本身。用户需要手动实现一种方法来在运行时定位这些库。

项目详情


下载文件

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

源分发

auditwheel_emscripten-0.0.16.tar.gz (5.8 MB 查看哈希值

上传时间

构建分发

auditwheel_emscripten-0.0.16-py3-none-any.whl (31.6 kB 查看哈希值

上传时间 Python 3

由以下组织支持