针对Pyodide的auditwheel-like工具
项目描述
auditwheel-emscripten
针对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所需的。
此工具基于
- 不严格记录的Emscripten动态链接规范:https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
- Emscripten的内部工具,用于检查WASM模块:https://github.com/emscripten-core/emscripten/blob/main/tools/webassembly.py
- Emscripten dylink实现:https://github.com/emscripten-core/emscripten/blob/main/src/library_dylink.js
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.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 049ba7ef502921aec655f61a69362716de3c043694c294494f73909e805bc1a4 |
|
MD5 | 5aac3199702fc83491743b6cf6641ce0 |
|
BLAKE2b-256 | ff3022e9f27fad0bfa5525ab805b84d7118b0bd1fbdbb26122e0c2653d74f2f1 |
关闭
auditwheel_emscripten-0.0.16-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0629cd66430d8b26497ff1edcef301cdbc459d6c86d295451895c88b7ad2dc42 |
|
MD5 | 48c1a0e34ba2556d8d808c79b8689730 |
|
BLAKE2b-256 | 09fc9af84495e4810ed1a2d16638688c7f83fca4884d4043c1f1613b55e51a88 |