- 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
64 lines
2.5 KiB
Python
64 lines
2.5 KiB
Python
import argparse
|
|
import os
|
|
import sys
|
|
|
|
from . import detect, repack, rebuild
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
description="EcoArk HarmonyOS Wheel Pipeline — repack / rebuild Python wheels for HarmonyOS/arm64"
|
|
)
|
|
parser.add_argument("input", help="Path to a .whl file")
|
|
parser.add_argument("--output-dir", "-o", default="output", help="Output directory (default: ./output)")
|
|
parser.add_argument("--target-os", default="harmonyos", choices=["harmonyos", "linux", "ohos"])
|
|
parser.add_argument("--arch", default="arm64", choices=["arm64", "aarch64", "x86_64"])
|
|
parser.add_argument("--force-native", action="store_true", help="Treat as native wheel even if detection says pure")
|
|
parser.add_argument("--force-repack", action="store_true", help="Force repack even for native wheels")
|
|
args = parser.parse_args()
|
|
|
|
input_path = args.input
|
|
if not os.path.isfile(input_path):
|
|
print(f"Error: input file not found: {input_path}", file=sys.stderr)
|
|
sys.exit(1)
|
|
if not input_path.endswith(".whl"):
|
|
print(f"Error: input must be a .whl file, got: {input_path}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
info = detect.detect_wheel_type(input_path)
|
|
if "error" in info:
|
|
print(f"Error: {info['error']}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
print(f"[pipeline] Input : {info['wheel']}")
|
|
print(f"[pipeline] Pure Py : {info['pure_python']}")
|
|
print(f"[pipeline] Detail : {info['detail']}")
|
|
|
|
output_dir = os.path.abspath(args.output_dir)
|
|
os.makedirs(output_dir, exist_ok=True)
|
|
|
|
is_native = info["native"] or args.force_native
|
|
|
|
if not is_native:
|
|
print("[pipeline] Pure Python wheel — repack with harmonyos tag")
|
|
out = repack.repack_wheel(input_path, output_dir)
|
|
print(f"[pipeline] Output : {out}")
|
|
print("[pipeline] Done — wheel can be installed directly on HarmonyOS.")
|
|
else:
|
|
if args.force_repack:
|
|
print("[pipeline] Pure wheel detected but force-repack requested.")
|
|
out = repack.repack_wheel(input_path, output_dir)
|
|
print(f"[pipeline] Repacked : {out}")
|
|
else:
|
|
print("[pipeline] Native wheel — needs cross-compilation.")
|
|
out = rebuild.rebuild_native_wheel(
|
|
input_path, output_dir,
|
|
target_os=args.target_os, arch=args.arch,
|
|
)
|
|
print(f"[pipeline] Output : {out}")
|
|
print("[pipeline] Done — native rebuild entry point triggered.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|