|
156 | 156 | # parser. --exclude does not help: it only drops a SONAME from dependency |
157 | 157 | # grafting, while repair still parses every ELF listed in the wheel's RECORD. |
158 | 158 | # So the cdylib has to leave the wheel entirely and be reinserted after. |
| 159 | + # Use pure-Python stash/remove (Info-ZIP path globs are unreliable here). |
159 | 160 | GOTTER_STASH_DIR="${WORK_DIR}/heap_gotter_stash" |
160 | | - GOTTER_PATTERN='*libdd_heap_gotter*.so' |
161 | | - if unzip -l "${BUILT_WHEEL_FILE}" | grep -q 'libdd_heap_gotter.*\.so$'; then |
162 | | - mkdir -p "${GOTTER_STASH_DIR}" |
163 | | - unzip -q "${BUILT_WHEEL_FILE}" "${GOTTER_PATTERN}" -d "${GOTTER_STASH_DIR}" |
164 | | - uv run --no-project scripts/zip_filter.py "${BUILT_WHEEL_FILE}" "${GOTTER_PATTERN}" |
165 | | - fi |
| 161 | + mkdir -p "${GOTTER_STASH_DIR}" |
| 162 | + BUILT_WHEEL_FILE="${BUILT_WHEEL_FILE}" GOTTER_STASH_DIR="${GOTTER_STASH_DIR}" \ |
| 163 | + uv run --no-project python - <<'PY' |
| 164 | +import os |
| 165 | +import zipfile |
| 166 | +from pathlib import Path |
| 167 | +
|
| 168 | +import subprocess |
| 169 | +import sys |
| 170 | +
|
| 171 | +wheel = Path(os.environ["BUILT_WHEEL_FILE"]) |
| 172 | +stash = Path(os.environ["GOTTER_STASH_DIR"]) |
| 173 | +marker = "libdd_heap_gotter" |
| 174 | +with zipfile.ZipFile(wheel, "r") as zf: |
| 175 | + gotter = [n for n in zf.namelist() if marker in Path(n).name and n.endswith(".so")] |
| 176 | + for name in gotter: |
| 177 | + dest = stash / name |
| 178 | + dest.parent.mkdir(parents=True, exist_ok=True) |
| 179 | + dest.write_bytes(zf.read(name)) |
| 180 | + print(f"Stashed heap-gotter cdylib: {name}") |
| 181 | +if gotter: |
| 182 | + # Remove via zip_filter so RECORD stays consistent. |
| 183 | + patterns = [f"*{marker}*.so", f"*/{marker}*.so"] |
| 184 | + subprocess.check_call([sys.executable, "scripts/zip_filter.py", str(wheel), *patterns]) |
| 185 | +with zipfile.ZipFile(wheel, "r") as zf: |
| 186 | + leftover = [n for n in zf.namelist() if marker in Path(n).name and n.endswith(".so")] |
| 187 | +if leftover: |
| 188 | + raise SystemExit(f"heap-gotter still in wheel before auditwheel: {leftover}") |
| 189 | +print(f"heap-gotter stash count before auditwheel: {len(gotter)}") |
| 190 | +PY |
166 | 191 |
|
167 | 192 | auditwheel repair -w "${TMP_WHEEL_DIR}" "${BUILT_WHEEL_FILE}" |
168 | 193 |
|
169 | | - if [[ -d "${GOTTER_STASH_DIR}" ]]; then |
| 194 | + if find "${GOTTER_STASH_DIR}" -name 'libdd_heap_gotter*.so' 2>/dev/null | grep -q .; then |
170 | 195 | REPAIRED_WHEEL_FILE=$(ls "${TMP_WHEEL_DIR}"/*.whl | head -n 1) |
171 | 196 | GOTTER_STASH_DIR="${GOTTER_STASH_DIR}" REPAIRED_WHEEL_FILE="${REPAIRED_WHEEL_FILE}" \ |
172 | 197 | uv run --no-project python - <<'PY' |
|
0 commit comments