@@ -15,7 +15,8 @@ def __init__(
1515 sub_dir : list [str ] | None = None ,
1616 sample : bool = False , copy_from_sample : bool = False ,
1717 read_sample_only : bool = False ,
18- is_mock : bool = False
18+ is_mock : bool = False ,
19+ prefer_bundled_config : bool = False ,
1920 ):
2021 self .instance_idx : int | None = instance_idx
2122 """传入时 该配置为一个的脚本实例独有的配置"""
@@ -32,6 +33,9 @@ def __init__(
3233 self .is_mock : bool = is_mock
3334 """mock情况下 不读取文件 也不会实际保存 用于测试"""
3435
36+ self ._prefer_bundled_config : bool = prefer_bundled_config
37+ """是否优先读取 PyInstaller 包内的配置"""
38+
3539 self ._sample : bool = sample
3640 """是否有sample文件"""
3741
@@ -68,6 +72,15 @@ def _get_yaml_file_paths(self) -> tuple[str | None, str | None, str | None]:
6872 if self ._read_sample_only and os .path .exists (sample_yml_path ):
6973 return sample_yml_path , sample_yml_path , None
7074
75+ if self ._prefer_bundled_config :
76+ resource_path = os_utils .get_resource_path (
77+ * sub_dir ,
78+ f'{ self .module_name } .yml' ,
79+ prefer_bundled = True ,
80+ )
81+ if resource_path != yml_path and os .path .exists (resource_path ):
82+ return resource_path , yml_path , resource_path
83+
7184 # 指定文件存在时 直接使用
7285 if os .path .exists (yml_path ):
7386 return yml_path , yml_path , None
0 commit comments