#!/usr/bin/env python3 """Build a development app, then execute Cargo's exact artifact with literal argv.""" import os import subprocess import sys from pathlib import Path from runtime_artifacts import build_executable def main(): if len(sys.argv) < 2: raise ValueError("usage: dev-run-app [arguments...]") repository = Path( os.environ.get("HEARTHSPACE_REPO_ROOT", Path(__file__).resolve().parents[1]) ).resolve() executable = build_executable(sys.argv[1], repository) os.chdir(repository) os.execv(executable, [str(executable), *sys.argv[2:]]) if __name__ == "__main__": try: main() except subprocess.CalledProcessError as error: raise SystemExit(error.returncode) from None except (OSError, ValueError, RuntimeError) as error: print(f"dev-run-app: {error}", file=sys.stderr) raise SystemExit(1) from None