- 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
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
import os
|
|
import sys
|
|
|
|
|
|
def rebuild_native_wheel(wheel_path: str, output_dir: str, target_os: str = "harmonyos", arch: str = "arm64") -> str:
|
|
basename = os.path.basename(wheel_path)
|
|
print(f"[rebuild] Native wheel rebuild triggered: {basename}")
|
|
print(f"[rebuild] Target: {target_os}/{arch}")
|
|
print(f"[rebuild] Output: {output_dir}")
|
|
print()
|
|
print(" Native extension rebuild for HarmonyOS requires:")
|
|
print(" - HarmonyOS SDK / OHOS NDK")
|
|
print(" - Cross-compilation toolchain for arm64")
|
|
print(" - Python headers matching the target Python build")
|
|
print(" - All C/Fortran source dependencies ported to HarmonyOS")
|
|
print()
|
|
print(" This entry point will be fleshed out in a future iteration.")
|
|
print(" For now, the source wheel is copied as-is for manual inspection.")
|
|
print()
|
|
|
|
output_path = os.path.join(output_dir, basename)
|
|
os.makedirs(output_dir, exist_ok=True)
|
|
|
|
with open(wheel_path, "rb") as src, open(output_path, "wb") as dst:
|
|
while True:
|
|
buf = src.read(65536)
|
|
if not buf:
|
|
break
|
|
dst.write(buf)
|
|
|
|
print(f"[rebuild] Copied original wheel to: {output_path}")
|
|
|
|
stub_path = output_path.replace(".whl", f"_{target_os}_{arch}_stub.txt")
|
|
with open(stub_path, "w") as f:
|
|
f.write(f"Native rebuild stub for {basename} ({target_os}/{arch})\n")
|
|
f.write("Replace this file with the actual rebuilt harmonyos wheel.\n")
|
|
|
|
print(f"[rebuild] Stub marker: {stub_path}")
|
|
return output_path
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python -m pipeline.rebuild <wheel.whl> [output_dir]")
|
|
sys.exit(1)
|
|
rebuild_native_wheel(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "output")
|