有一种方法,但它有点违背了审计轮修复的目的。
您需要将 auditwheel 安装为 Python 模块,然后将其导入您自己的 Python 脚本并猴子修补一些指定修复策略的值。
# Monkey patch to not ship libjvm.so in pypi wheels
import sys
from auditwheel.main import main
from auditwheel.policy import _POLICIES as POLICIES
# libjvm is loaded dynamically; do not include it
for p in POLICIES:
p['lib_whitelist'].append('libjvm.so')
if __name__ == "__main__":
sys.exit(main())
这个片段来自diplib项目,它可以满足您对 Java 库的期望。您需要修改此脚本以涵盖您需要列入白名单的库。
然后需要由 Python 3.x 解释器调用此脚本,否则它将失败。如果需要,您可以通过这种方式修复 Python 2.7 轮子。diplib 项目还展示了一个需要在 manylinux docker 容器中进行的示例调用。
#!/bin/bash
# Run this in a manylinux2010 docker container with /io mounted to some local directory
# ...
/opt/python/cp37-cp37m/bin/python -m pip install cmake auditwheel # ignore "cmake"
# ...
export AUDITWHEEL=`pwd`/diplib/tools/travis/auditwheel # the monkey patch script
# ...
/opt/python/cp37-cp37m/bin/python $AUDITWHEEL repair pydip/staging/dist/*.whl
# ...