"""Smoke-test the HALCON environment on this machine. Verifies: the Python binding loads, the native runtime links, the license is valid (a real operator runs), and HDevEngine imports. Run (from the project dir, via uv): /mnt/c/Users/NAURA/.local/bin/uv.exe run python .claude/skills/halcon/scripts/check_env.py """ import sys def main() -> int: try: import halcon as ha except Exception as e: # binding not installed / wrong interpreter print("FAIL: could not import 'halcon'. Are you running the project venv " "via uv? Error:", e) return 1 try: print("HALCON library version:", ha.get_system("version")) img = ha.gen_image_const("byte", 64, 48) # exercises the license w = ha.get_image_size(img) print("gen_image_const OK, size (w,h):", w) region = ha.threshold(img, 0, 128) area, _, _ = ha.area_center(region) print("threshold + area_center OK, area:", area) except Exception as e: print("FAIL: an operator call failed. This is usually a LICENSE problem " "(missing/expired monthly .dat in \\license\\). Error:", e) return 2 try: from halcon.hdevengine import HDevEngine # noqa: F401 print("HDevEngine import OK") except Exception as e: print("WARN: HDevEngine import failed:", e) return 3 print("HALCON environment OK") return 0 if __name__ == "__main__": sys.exit(main())