diff --git a/bin/run_cli.py b/bin/run_cli.py index dc48505..7aecbd6 100644 --- a/bin/run_cli.py +++ b/bin/run_cli.py @@ -95,10 +95,11 @@ except Exception as e: logging.debug("外部模块路径配置失败: %s", e) # 在导入 PaddleOCR 之前设置,避免每次启动都做连通性检查提示并抑制底层 glog/oneDNN 等噪音 -# DISABLE_MODEL_SOURCE_CHECK: 跳过 PaddleOCR 的主机连通性检查(国内网络环境常卡) +# DISABLE_MODEL_SOURCE_CHECK/PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK: 跳过 PaddleOCR/PaddleX 主机连通性检查(国内网络环境常卡) # GLOG_minloglevel: 2 -> ERROR 及以上,屏蔽 INFO/WARNING # OMP_NUM_THREADS: 设为 1,避免 oneDNN 打印线程信息 os.environ.setdefault("DISABLE_MODEL_SOURCE_CHECK", "True") +os.environ.setdefault("PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK", "1") os.environ.setdefault("GLOG_minloglevel", "2") os.environ.setdefault("OMP_NUM_THREADS", "1") diff --git a/douyin/core/underlying_operations.py b/douyin/core/underlying_operations.py index 99ee84f..4c89978 100644 --- a/douyin/core/underlying_operations.py +++ b/douyin/core/underlying_operations.py @@ -8,6 +8,7 @@ import warnings # PaddleOCR 3.x 会在初始化/导入时进行模型源连通性检查;在国内网络环境下容易卡住。 # 这里提前设置环境变量,避免启动耗时/卡死。 os.environ.setdefault("DISABLE_MODEL_SOURCE_CHECK", "True") +os.environ.setdefault("PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK", "1") # 额外抑制 paddle/oneDNN/glog 的冗余信息(INFO/WARNING) os.environ.setdefault("GLOG_minloglevel", "2") os.environ.setdefault("OMP_NUM_THREADS", "1") diff --git a/operations/ocr_operations.py b/operations/ocr_operations.py index daad0e0..9f829af 100644 --- a/operations/ocr_operations.py +++ b/operations/ocr_operations.py @@ -15,6 +15,7 @@ from typing import Any # PaddleOCR 3.x 会在初始化/导入时进行模型源连通性检查;在国内网络环境下容易卡住。 # 这里提前设置环境变量,避免启动耗时/卡死。 os.environ.setdefault("DISABLE_MODEL_SOURCE_CHECK", "True") +os.environ.setdefault("PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK", "1") # 额外抑制 paddle/oneDNN/glog 的冗余信息(INFO/WARNING) os.environ.setdefault("GLOG_minloglevel", "2") # Win + Paddle 3.x:oneDNN 后端跟新 PIR 执行器有 ConvertPirAttribute2RuntimeAttribute 不兼容 bug。 diff --git a/packaging/pyinstaller/build_windows.ps1 b/packaging/pyinstaller/build_windows.ps1 index 55748e6..779a11c 100644 --- a/packaging/pyinstaller/build_windows.ps1 +++ b/packaging/pyinstaller/build_windows.ps1 @@ -12,6 +12,13 @@ $ErrorActionPreference = "Stop" $Root = Resolve-Path (Join-Path $PSScriptRoot "..\..") Set-Location $Root +$env:DISABLE_MODEL_SOURCE_CHECK = "True" +$env:PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK = "1" +$env:SKIP_OCR_INIT = "1" +$env:GLOG_minloglevel = "2" +$env:FLAGS_use_mkldnn = "false" +$env:FLAGS_call_stack_level = "0" + if (-not $Version) { $Version = (python -c "from douyin.core.version import APP_VERSION; print(str(APP_VERSION).lstrip('Vv'))").Trim() } diff --git a/tests/test_obfuscation_staging.py b/tests/test_obfuscation_staging.py index efb9b84..92eb2f7 100644 --- a/tests/test_obfuscation_staging.py +++ b/tests/test_obfuscation_staging.py @@ -191,6 +191,12 @@ def test_windows_packaging_script_exposes_obfuscate_switch(): assert "[switch]$Obfuscate" in script assert "tools.obfuscation_staging" in script + assert '$env:DISABLE_MODEL_SOURCE_CHECK = "True"' in script + assert '$env:PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK = "1"' in script + assert '$env:SKIP_OCR_INIT = "1"' in script + assert '$env:GLOG_minloglevel = "2"' in script + assert '$env:FLAGS_use_mkldnn = "false"' in script + assert '$env:FLAGS_call_stack_level = "0"' in script assert "--hidden-imports-output $HiddenImportsFile" in script assert "ConvertFrom-Json" in script assert '$CliOnlyHiddenImportRoots = @("cv2", "numpy", "paddleocr", "paddle")' in script diff --git a/tests/test_startup_update_bootstrap.py b/tests/test_startup_update_bootstrap.py index b821444..f5b0572 100644 --- a/tests/test_startup_update_bootstrap.py +++ b/tests/test_startup_update_bootstrap.py @@ -86,3 +86,13 @@ def test_run_cli_import_does_not_trigger_startup_update(monkeypatch): assert proc.returncode == 0 assert "import-ok" in proc.stdout + + +def test_paddlex_model_source_check_disabled_before_runtime_imports(): + for path in ( + "bin/run_cli.py", + "operations/ocr_operations.py", + "douyin/core/underlying_operations.py", + ): + text = Path(path).read_text(encoding="utf-8") + assert "PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK" in text