#!/usr/bin/env python3 """ PaddleX 服务启动包装器 - 自动激活适配器 """ import os import sys import subprocess def main(): # 🎯 在当前进程中激活适配器 if os.getenv("PADDLEX_ENABLE_TABLE_ADAPTER", "").lower() in ("true", "1", "yes"): sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'adapters')) try: from adapters import apply_table_recognition_adapter if apply_table_recognition_adapter(): print("✅ Adapter activated in wrapper process") except Exception as e: print(f"⚠️ Failed to activate adapter: {e}") # 🎯 解析命令行参数 args = sys.argv[1:] # 去掉脚本名 # 🎯 导入 PaddleX CLI 主函数并在当前进程执行 from paddlex.paddlex_cli import main as paddlex_main # 替换 sys.argv 以传递参数 sys.argv = ['paddlex'] + args # 执行 PaddleX paddlex_main() if __name__ == "__main__": main()