|
37 | 37 | --ndk "$ANDROID_NDK_ROOT" \ |
38 | 38 | --out-dir dist/libpython |
39 | 39 |
|
| 40 | + - name: inject SSL libs into wheels |
| 41 | + run: | |
| 42 | + python3 - <<'PYEOF' |
| 43 | + import zipfile, re |
| 44 | + from pathlib import Path |
| 45 | +
|
| 46 | + work_dir = Path("ksproject/.build-target") |
| 47 | + wheel_dir = Path("dist/libpython") |
| 48 | + abi_map = {"arm64_v8a": "arm64-v8a", "x86_64": "x86_64"} |
| 49 | +
|
| 50 | + for whl_path in sorted(wheel_dir.rglob("*.whl")): |
| 51 | + m = re.search(r"android_\d+_(\w+)$", whl_path.stem) |
| 52 | + if not m: |
| 53 | + continue |
| 54 | + abi_tag = m.group(1) |
| 55 | + abi = abi_map.get(abi_tag, abi_tag) |
| 56 | +
|
| 57 | + ssl_so = next(work_dir.rglob(f"*{abi}*/lib/libssl_python.so"), None) |
| 58 | + cryp_so = next(work_dir.rglob(f"*{abi}*/lib/libcrypto_python.so"), None) |
| 59 | + extra = [p for p in (ssl_so, cryp_so) if p] |
| 60 | +
|
| 61 | + if not extra: |
| 62 | + print(f"WARNING: no SSL .so found for {abi}, skipping") |
| 63 | + continue |
| 64 | +
|
| 65 | + print(f"Patching {whl_path.name}: adding {[p.name for p in extra]}") |
| 66 | + tmp = whl_path.with_name(whl_path.name + ".tmp") |
| 67 | + with zipfile.ZipFile(whl_path, "r") as zin, \ |
| 68 | + zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED, compresslevel=9) as zout: |
| 69 | + for item in zin.infolist(): |
| 70 | + zout.writestr(item, zin.read(item.filename)) |
| 71 | + for lib in extra: |
| 72 | + arcname = f"libpython/prefix/{abi}/lib/{lib.name}" |
| 73 | + print(f" + {arcname}") |
| 74 | + zout.write(str(lib), arcname) |
| 75 | + whl_path.unlink() |
| 76 | + tmp.rename(whl_path) |
| 77 | + PYEOF |
| 78 | +
|
40 | 79 | - run: find dist/libpython -name "*.whl" |
41 | 80 |
|
42 | 81 | - uses: actions/upload-artifact@v4 |
|
0 commit comments