Files
ecoarkpywhl/pipeline/detect.py
root 8d9a757ef5 feat: initial EcoArk HarmonyOS wheel pipeline skeleton
- wheel_pipeline.py: CLI entry point for repack/rebuild flow
- pipeline/detect.py: detect pure vs native extension wheels
- pipeline/repack.py: repack pure-Python wheels with harmonyos_arm64 tag
- pipeline/rebuild.py: native wheel rebuild entry (stub for OHOS NDK)
- pipeline/cli.py: argument parsing and orchestration
- Makefile: convenience targets (repack, rebuild, clean)
- README.md: documentation with usage and limitations
- examples/gen_test_wheels.py: test wheel generator
- output/: output directory for generated wheels
2026-05-13 11:36:13 +08:00

44 lines
1.3 KiB
Python

import zipfile
import os
import re
PURE_TAGS = {"py2", "py3", "py2.py3", "none", "any"}
def detect_wheel_type(wheel_path: str) -> dict:
if not os.path.isfile(wheel_path):
return {"error": f"File not found: {wheel_path}"}
if not wheel_path.endswith(".whl"):
return {"error": "Not a .whl file"}
basename = os.path.basename(wheel_path)
parts = basename.split("-")
platform_tag = parts[-1].replace(".whl", "") if len(parts) >= 4 else "unknown"
abi_tag = parts[-2] if len(parts) >= 4 else "unknown"
has_native = False
native_detail = ""
if platform_tag not in PURE_TAGS or abi_tag != "none":
has_native = True
native_detail = f"platform={platform_tag}, abi={abi_tag}"
if not has_native:
try:
with zipfile.ZipFile(wheel_path) as zf:
for name in zf.namelist():
if name.endswith((".so", ".pyd", ".dll", ".dylib")):
has_native = True
native_detail = f"contains native extension: {name}"
break
except zipfile.BadZipFile:
return {"error": "Corrupt or invalid zip file"}
return {
"wheel": basename,
"pure_python": not has_native,
"native": has_native,
"detail": native_detail or "tag=any/none, no native binaries found",
}