unifypy 2.0.8__tar.gz → 2.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. {unifypy-2.0.8/unifypy.egg-info → unifypy-2.0.9}/PKG-INFO +1 -1
  2. {unifypy-2.0.8 → unifypy-2.0.9}/pyproject.toml +1 -1
  3. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/config.py +42 -10
  4. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/environment.py +9 -4
  5. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/macos/post_processor.py +7 -2
  6. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/pyinstaller/config_builder.py +7 -8
  7. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/command_runner.py +54 -8
  8. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/icon_converter.py +15 -2
  9. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/info_plist_updater.py +26 -3
  10. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/macos_codesign.py +33 -4
  11. {unifypy-2.0.8 → unifypy-2.0.9/unifypy.egg-info}/PKG-INFO +1 -1
  12. {unifypy-2.0.8 → unifypy-2.0.9}/LICENSE +0 -0
  13. {unifypy-2.0.8 → unifypy-2.0.9}/MANIFEST.in +0 -0
  14. {unifypy-2.0.8 → unifypy-2.0.9}/README.md +0 -0
  15. {unifypy-2.0.8 → unifypy-2.0.9}/setup.cfg +0 -0
  16. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/__init__.py +0 -0
  17. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/__main__.py +0 -0
  18. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/cli/__init__.py +0 -0
  19. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/cli/argument_parser.py +0 -0
  20. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/cli/interactive/__init__.py +0 -0
  21. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/cli/interactive/config_definitions.py +0 -0
  22. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/cli/interactive/input_handlers.py +0 -0
  23. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/cli/interactive/interactive_menu.py +0 -0
  24. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/cli/interactive/project_scanner.py +0 -0
  25. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/cli/interactive/wizard.py +0 -0
  26. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/__init__.py +0 -0
  27. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/context.py +0 -0
  28. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/engine.py +0 -0
  29. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/event_bus.py +0 -0
  30. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/events.py +0 -0
  31. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/platforms.py +0 -0
  32. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/plugin.py +0 -0
  33. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/validators/__init__.py +0 -0
  34. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/core/validators/tool_validator.py +0 -0
  35. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/__init__.py +0 -0
  36. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/base.py +0 -0
  37. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/linux/__init__.py +0 -0
  38. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/linux/appimage_packager.py +0 -0
  39. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/linux/deb_packager.py +0 -0
  40. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/linux/rpm_packager.py +0 -0
  41. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/macos/__init__.py +0 -0
  42. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/macos/dmg_packager.py +0 -0
  43. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/registry.py +0 -0
  44. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/windows/__init__.py +0 -0
  45. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/platforms/windows/inno_setup.py +0 -0
  46. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/__init__.py +0 -0
  47. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/auto_rollback_plugin.py +0 -0
  48. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/cleanup_plugin.py +0 -0
  49. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/config_plugin.py +0 -0
  50. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/dry_run_plugin.py +0 -0
  51. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/environment_plugin.py +0 -0
  52. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/external_plugins_loader.py +0 -0
  53. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/packaging_plugin.py +0 -0
  54. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/prepare_plugin.py +0 -0
  55. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/progress_plugin.py +0 -0
  56. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/pyinstaller_plugin.py +0 -0
  57. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/rollback_plugin.py +0 -0
  58. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/summary_plugin.py +0 -0
  59. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/plugins/windows_language_plugin.py +0 -0
  60. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/pyinstaller/__init__.py +0 -0
  61. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/templates/ChineseSimplified.isl.template +0 -0
  62. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/templates/setup.iss.template +0 -0
  63. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/.this-is-the-create-dmg-repo +0 -0
  64. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/LICENSE +0 -0
  65. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/Makefile +0 -0
  66. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/README.md +0 -0
  67. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/builder/create-dmg.builder +0 -0
  68. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/create-dmg +0 -0
  69. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/doc-project/Developer Notes.md +0 -0
  70. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/doc-project/Release Checklist.md +0 -0
  71. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/examples/01-main-example/installer_background.png +0 -0
  72. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/examples/01-main-example/sample +0 -0
  73. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/examples/01-main-example/source_folder/Application.app +0 -0
  74. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/support/eula-resources-template.xml +0 -0
  75. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/support/template.applescript +0 -0
  76. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/tests/007-space-in-dir-name/my files/hello.txt +0 -0
  77. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/tools/create-dmg/tests/007-space-in-dir-name/run-test +0 -0
  78. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/__init__.py +0 -0
  79. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/cache_manager.py +0 -0
  80. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/entitlements_generator.py +0 -0
  81. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/file_ops.py +0 -0
  82. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/parallel_builder.py +0 -0
  83. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/progress.py +0 -0
  84. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/progress_callback_factory.py +0 -0
  85. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/rollback.py +0 -0
  86. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy/utils/tool_manager.py +0 -0
  87. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy.egg-info/SOURCES.txt +0 -0
  88. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy.egg-info/dependency_links.txt +0 -0
  89. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy.egg-info/entry_points.txt +0 -0
  90. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy.egg-info/requires.txt +0 -0
  91. {unifypy-2.0.8 → unifypy-2.0.9}/unifypy.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unifypy
3
- Version: 2.0.8
3
+ Version: 2.0.9
4
4
  Summary: UnifyPy 2.0 - Cross-platform Python app packaging tool
5
5
  Author: Junsen Huang
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "unifypy"
7
- version = "2.0.8"
7
+ version = "2.0.9"
8
8
  description = "UnifyPy 2.0 - Cross-platform Python app packaging tool"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -213,6 +213,33 @@ class ConfigManager:
213
213
  except Exception as e:
214
214
  raise Exception(f"加载配置文件失败: {e}")
215
215
 
216
+ def _deep_merge(self, base: dict, override: dict) -> dict:
217
+ """递归深度合并字典.
218
+
219
+ Args:
220
+ base: 基础配置
221
+ override: 覆盖配置
222
+
223
+ Returns:
224
+ 合并后的配置
225
+
226
+ 规则:
227
+ - override 中存在的键直接覆盖 base 的值
228
+ - 如果值都是字典,递归合并
229
+ - base 中存在但 override 中不存在的键保留
230
+ """
231
+ result = base.copy()
232
+
233
+ for key, value in override.items():
234
+ if key in result and isinstance(result[key], dict) and isinstance(value, dict):
235
+ # 递归合并嵌套字典
236
+ result[key] = self._deep_merge(result[key], value)
237
+ else:
238
+ # 直接覆盖(字符串、数字、列表等)
239
+ result[key] = value
240
+
241
+ return result
242
+
216
243
  def _merge_all_configs(self) -> Dict[str, Any]:
217
244
  """合并所有配置源 优先级: 命令行参数 > 平台特定配置 > 全局配置 > 默认配置.
218
245
 
@@ -225,24 +252,24 @@ class ConfigManager:
225
252
  # 从原始配置开始
226
253
  merged = default_config.copy()
227
254
 
228
- # 合并文件配置的全局部分
255
+ # 深度合并文件配置的全局部分
229
256
  if self.raw_config:
230
257
  global_config = {
231
258
  k: v
232
259
  for k, v in self.raw_config.items()
233
260
  if k not in ["platform_specific", "platforms"]
234
261
  }
235
- merged.update(global_config)
262
+ merged = self._deep_merge(merged, global_config)
236
263
 
237
- # 合并平台特定配置
264
+ # 深度合并平台特定配置
238
265
  platform_config = self._get_platform_config()
239
266
  if platform_config:
240
- merged.update(platform_config)
267
+ merged = self._deep_merge(merged, platform_config)
241
268
 
242
- # 合并命令行参数
269
+ # 深度合并命令行参数
243
270
  if self.args:
244
271
  args_config = self._args_to_config(self.args)
245
- merged.update(args_config)
272
+ merged = self._deep_merge(merged, args_config)
246
273
 
247
274
  return merged
248
275
 
@@ -434,13 +461,18 @@ class ConfigManager:
434
461
  if value is not None:
435
462
  config[key] = value
436
463
 
437
- # 获取pyinstaller节中的配置
464
+ # 深度合并根级 pyinstaller 节
438
465
  pyinstaller_section = self.get("pyinstaller", {})
439
- config.update(pyinstaller_section)
466
+ config = self._deep_merge(config, pyinstaller_section)
440
467
 
441
- # 处理平台特定的PyInstaller配置
468
+ # 深度合并平台特定的PyInstaller配置
442
469
  platform_pyinstaller = self._get_platform_config().get("pyinstaller", {})
443
- config.update(platform_pyinstaller)
470
+ config = self._deep_merge(config, platform_pyinstaller)
471
+
472
+ # 深度合并命令行参数中的 PyInstaller 配置(如果有)
473
+ if self.args:
474
+ args_pyinstaller = self._args_to_config(self.args).get("pyinstaller", {})
475
+ config = self._deep_merge(config, args_pyinstaller)
444
476
 
445
477
  # 添加 macOS 特定的配置
446
478
  if self.current_platform == "macos":
@@ -8,6 +8,7 @@
8
8
  import platform
9
9
  import subprocess
10
10
  import os
11
+ import locale
11
12
  from pathlib import Path
12
13
  from typing import Any, Dict, Optional
13
14
 
@@ -93,9 +94,11 @@ class EnvironmentManager:
93
94
  try:
94
95
  # 检测 ldd --version 是否包含 musl
95
96
  result = subprocess.run(
96
- ["ldd", "--version"],
97
- capture_output=True,
98
- text=True,
97
+ ["ldd", "--version"],
98
+ capture_output=True,
99
+ text=True,
100
+ encoding=locale.getpreferredencoding(False) or 'utf-8',
101
+ errors='replace',
99
102
  timeout=5
100
103
  )
101
104
  output = result.stderr.lower() + result.stdout.lower()
@@ -126,12 +129,14 @@ class EnvironmentManager:
126
129
  """
127
130
  if self.current_platform != "mac":
128
131
  return False
129
-
132
+
130
133
  try:
131
134
  result = subprocess.run(
132
135
  ["sysctl", "-in", "sysctl.proc_translated"],
133
136
  capture_output=True,
134
137
  text=True,
138
+ encoding=locale.getpreferredencoding(False) or 'utf-8',
139
+ errors='replace',
135
140
  timeout=5
136
141
  )
137
142
  return result.stdout.strip() == "1"
@@ -349,12 +349,15 @@ class MacOSPostProcessor:
349
349
  """
350
350
  try:
351
351
  import subprocess
352
+ import locale
352
353
 
353
354
  # 验证签名
354
355
  result = subprocess.run(
355
356
  ['codesign', '-dv', '--verbose=4', str(app_path)],
356
357
  capture_output=True,
357
- text=True
358
+ text=True,
359
+ encoding=locale.getpreferredencoding(False) or 'utf-8',
360
+ errors='replace',
358
361
  )
359
362
 
360
363
  if result.returncode == 0:
@@ -367,7 +370,9 @@ class MacOSPostProcessor:
367
370
  entitlements_result = subprocess.run(
368
371
  ['codesign', '-d', '--entitlements', ':-', str(app_path)],
369
372
  capture_output=True,
370
- text=True
373
+ text=True,
374
+ encoding=locale.getpreferredencoding(False) or 'utf-8',
375
+ errors='replace',
371
376
  )
372
377
 
373
378
  if entitlements_result.returncode == 0 and entitlements_result.stdout:
@@ -271,13 +271,6 @@ class PyInstallerConfigBuilder:
271
271
  collect_config = ""
272
272
  bundle_config = ""
273
273
  if not config.get("onefile", False):
274
- # 处理 contents_directory 选项
275
- contents_dir = config.get('contents_directory', None)
276
- contents_dir_line = ""
277
- if contents_dir is not None:
278
- # 如果明确指定了 contents_directory(包括空字符串),添加该参数
279
- contents_dir_line = f",\n contents_directory={repr(contents_dir)}"
280
-
281
274
  collect_config = f"""
282
275
  coll = COLLECT(exe,
283
276
  a.binaries,
@@ -285,7 +278,7 @@ coll = COLLECT(exe,
285
278
  a.datas,
286
279
  strip={str(config.get('strip', False))},
287
280
  upx={str(not config.get('noupx', False))},
288
- upx_exclude={repr(config.get('upx_exclude', []))}{contents_dir_line},
281
+ upx_exclude={repr(config.get('upx_exclude', []))},
289
282
  name={repr(app_name)})"""
290
283
 
291
284
  # 添加macOS Bundle配置
@@ -355,6 +348,7 @@ pyz = {pyz_config}
355
348
  version = config.get("version_file")
356
349
  uac_admin = config.get("uac_admin", False)
357
350
  uac_uiaccess = config.get("uac_uiaccess", False)
351
+ contents_directory = config.get("contents_directory")
358
352
 
359
353
  exe_config = """exe = EXE(
360
354
  pyz,
@@ -382,6 +376,11 @@ pyz = {pyz_config}
382
376
  console={str(console)},
383
377
  disable_windowed_traceback={str(disable_windowed_traceback)},"""
384
378
 
379
+ # contents_directory 参数(仅在 onedir 模式下有效)
380
+ if not config.get("onefile", False) and contents_directory is not None:
381
+ exe_config += f"""
382
+ contents_directory={repr(contents_directory)},"""
383
+
385
384
  if target_arch:
386
385
  exe_config += f"""
387
386
  target_arch={repr(target_arch)},"""
@@ -6,11 +6,38 @@
6
6
 
7
7
  import subprocess
8
8
  import sys
9
+ import locale
9
10
  from typing import List, Optional, Union
10
11
 
11
12
  from .progress import ProgressManager
12
13
 
13
14
 
15
+ def get_subprocess_encoding() -> str:
16
+ """
17
+ 获取 subprocess 输出的适当编码
18
+
19
+ 根据系统区域设置自动选择编码:
20
+ - Windows: 通常是 cp936(GBK), cp950(Big5), cp932(Shift-JIS) 等
21
+ - macOS/Linux: 通常是 UTF-8
22
+
23
+ Returns:
24
+ str: 编码名称
25
+ """
26
+ try:
27
+ # getpreferredencoding(False) 返回系统默认编码
28
+ # False 参数表示不使用 locale.CODESET(更可靠)
29
+ encoding = locale.getpreferredencoding(False)
30
+ if encoding and encoding.lower() not in (
31
+ 'ascii', 'ansi_x3.4-1968'
32
+ ):
33
+ return encoding
34
+ except Exception:
35
+ pass
36
+
37
+ # 回退到 UTF-8
38
+ return 'utf-8'
39
+
40
+
14
41
  class SilentRunner:
15
42
  """
16
43
  静默命令执行器,只在错误时输出.
@@ -58,6 +85,9 @@ class SilentRunner:
58
85
  self.progress.info(f"执行命令: {cmd_str}")
59
86
 
60
87
  try:
88
+ # 获取系统适当的编码
89
+ encoding = get_subprocess_encoding()
90
+
61
91
  # 执行命令
62
92
  if capture_output:
63
93
  result = subprocess.run(
@@ -65,7 +95,9 @@ class SilentRunner:
65
95
  shell=shell,
66
96
  capture_output=True,
67
97
  text=True,
68
- encoding="utf-8",
98
+ encoding=encoding,
99
+ # 无法解码的字节替换为 � (防止崩溃)
100
+ errors='replace',
69
101
  cwd=cwd,
70
102
  )
71
103
  else:
@@ -75,7 +107,9 @@ class SilentRunner:
75
107
  stdout=subprocess.PIPE,
76
108
  stderr=subprocess.PIPE,
77
109
  text=True,
78
- encoding="utf-8",
110
+ encoding=encoding,
111
+ # 无法解码的字节替换为 � (防止崩溃)
112
+ errors='replace',
79
113
  cwd=cwd,
80
114
  )
81
115
 
@@ -160,19 +194,27 @@ class SilentRunner:
160
194
  """
161
195
  try:
162
196
  result = subprocess.run(
163
- [tool_name, "--version"], capture_output=True, text=True
197
+ [tool_name, "--version"],
198
+ capture_output=True,
199
+ text=True,
200
+ encoding=get_subprocess_encoding(),
201
+ errors='replace',
164
202
  )
165
203
  return result.returncode == 0
166
204
  except FileNotFoundError:
167
205
  return False
168
- except:
206
+ except Exception:
169
207
  # 有些工具可能不支持--version,尝试--help
170
208
  try:
171
209
  result = subprocess.run(
172
- [tool_name, "--help"], capture_output=True, text=True
210
+ [tool_name, "--help"],
211
+ capture_output=True,
212
+ text=True,
213
+ encoding=get_subprocess_encoding(),
214
+ errors='replace',
173
215
  )
174
216
  return result.returncode == 0
175
- except:
217
+ except Exception:
176
218
  return False
177
219
 
178
220
  def get_tool_version(self, tool_name: str) -> Optional[str]:
@@ -186,10 +228,14 @@ class SilentRunner:
186
228
  """
187
229
  try:
188
230
  result = subprocess.run(
189
- [tool_name, "--version"], capture_output=True, text=True
231
+ [tool_name, "--version"],
232
+ capture_output=True,
233
+ text=True,
234
+ encoding=get_subprocess_encoding(),
235
+ errors='replace',
190
236
  )
191
237
  if result.returncode == 0:
192
238
  return result.stdout.strip()
193
- except:
239
+ except Exception:
194
240
  pass
195
241
  return None
@@ -10,6 +10,8 @@ import tempfile
10
10
  from pathlib import Path
11
11
  from typing import Optional
12
12
 
13
+ from .command_runner import get_subprocess_encoding
14
+
13
15
 
14
16
  class IconConverter:
15
17
  """
@@ -110,7 +112,12 @@ class IconConverter:
110
112
  # 使用 iconutil 转换为 ICNS
111
113
  cmd = ["iconutil", "-c", "icns", str(iconset_dir), "-o", str(icns_path)]
112
114
  result = subprocess.run(
113
- cmd, capture_output=True, text=True, check=False
115
+ cmd,
116
+ capture_output=True,
117
+ text=True,
118
+ encoding=get_subprocess_encoding(),
119
+ errors='replace',
120
+ check=False
114
121
  )
115
122
 
116
123
  if result.returncode == 0:
@@ -138,7 +145,13 @@ class IconConverter:
138
145
  "--out",
139
146
  str(target),
140
147
  ]
141
- result = subprocess.run(cmd, capture_output=True, check=False)
148
+ result = subprocess.run(
149
+ cmd,
150
+ capture_output=True,
151
+ encoding=get_subprocess_encoding(),
152
+ errors='replace',
153
+ check=False
154
+ )
142
155
  return result.returncode == 0
143
156
  except Exception:
144
157
  return False
@@ -8,6 +8,8 @@ import subprocess
8
8
  from pathlib import Path
9
9
  from typing import Any, Dict
10
10
 
11
+ from .command_runner import get_subprocess_encoding
12
+
11
13
 
12
14
  class InfoPlistUpdater:
13
15
  """
@@ -129,7 +131,12 @@ class InfoPlistUpdater:
129
131
  ]
130
132
 
131
133
  result = subprocess.run(
132
- add_cmd, capture_output=True, text=True, check=False
134
+ add_cmd,
135
+ capture_output=True,
136
+ text=True,
137
+ encoding=get_subprocess_encoding(),
138
+ errors='replace',
139
+ check=False
133
140
  )
134
141
 
135
142
  # 如果添加失败(可能已存在),尝试更新
@@ -142,7 +149,12 @@ class InfoPlistUpdater:
142
149
  ]
143
150
 
144
151
  result = subprocess.run(
145
- set_cmd, capture_output=True, text=True, check=False
152
+ set_cmd,
153
+ capture_output=True,
154
+ text=True,
155
+ encoding=get_subprocess_encoding(),
156
+ errors='replace',
157
+ check=False
146
158
  )
147
159
 
148
160
  return result.returncode == 0
@@ -170,6 +182,8 @@ class InfoPlistUpdater:
170
182
  str(plist_path),
171
183
  ],
172
184
  capture_output=True,
185
+ encoding=get_subprocess_encoding(),
186
+ errors='replace',
173
187
  check=False,
174
188
  )
175
189
 
@@ -182,6 +196,8 @@ class InfoPlistUpdater:
182
196
  str(plist_path),
183
197
  ],
184
198
  capture_output=True,
199
+ encoding=get_subprocess_encoding(),
200
+ errors='replace',
185
201
  check=False,
186
202
  )
187
203
 
@@ -201,6 +217,8 @@ class InfoPlistUpdater:
201
217
  str(plist_path),
202
218
  ],
203
219
  capture_output=True,
220
+ encoding=get_subprocess_encoding(),
221
+ errors='replace',
204
222
  check=False,
205
223
  )
206
224
 
@@ -235,7 +253,12 @@ class InfoPlistUpdater:
235
253
  ]
236
254
 
237
255
  result = subprocess.run(
238
- cmd, capture_output=True, text=True, check=False
256
+ cmd,
257
+ capture_output=True,
258
+ text=True,
259
+ encoding=get_subprocess_encoding(),
260
+ errors='replace',
261
+ check=False
239
262
  )
240
263
 
241
264
  if result.returncode == 0:
@@ -8,6 +8,8 @@ import subprocess
8
8
  from pathlib import Path
9
9
  from typing import Optional
10
10
 
11
+ from .command_runner import get_subprocess_encoding
12
+
11
13
 
12
14
  class MacOSCodeSigner:
13
15
  """
@@ -69,7 +71,14 @@ class MacOSCodeSigner:
69
71
 
70
72
  self._print(f" 🚀 执行签名命令: {' '.join(cmd)}")
71
73
 
72
- result = subprocess.run(cmd, capture_output=True, text=True, check=False)
74
+ result = subprocess.run(
75
+ cmd,
76
+ capture_output=True,
77
+ text=True,
78
+ encoding=get_subprocess_encoding(),
79
+ errors='replace',
80
+ check=False
81
+ )
73
82
 
74
83
  if result.returncode == 0:
75
84
  self._print(" ✅ 代码签名成功")
@@ -105,7 +114,13 @@ class MacOSCodeSigner:
105
114
  self.codesign_path if self.codesign_path else "/usr/bin/codesign"
106
115
  )
107
116
  cmd = [codesign_cmd, "--remove-signature", str(executable_path)]
108
- subprocess.run(cmd, capture_output=True, check=False)
117
+ subprocess.run(
118
+ cmd,
119
+ capture_output=True,
120
+ encoding=get_subprocess_encoding(),
121
+ errors='replace',
122
+ check=False
123
+ )
109
124
  return True
110
125
  except Exception:
111
126
  return True # 忽略移除签名的错误
@@ -125,7 +140,12 @@ class MacOSCodeSigner:
125
140
  str(info_plist),
126
141
  ]
127
142
  result = subprocess.run(
128
- cmd, capture_output=True, text=True, check=False
143
+ cmd,
144
+ capture_output=True,
145
+ text=True,
146
+ encoding=get_subprocess_encoding(),
147
+ errors='replace',
148
+ check=False
129
149
  )
130
150
 
131
151
  if result.returncode == 0:
@@ -155,7 +175,14 @@ class MacOSCodeSigner:
155
175
  self.codesign_path if self.codesign_path else "/usr/bin/codesign"
156
176
  )
157
177
  cmd = [codesign_cmd, "-dv", "--verbose=4", str(app_path)]
158
- result = subprocess.run(cmd, capture_output=True, text=True, check=False)
178
+ result = subprocess.run(
179
+ cmd,
180
+ capture_output=True,
181
+ text=True,
182
+ encoding=get_subprocess_encoding(),
183
+ errors='replace',
184
+ check=False
185
+ )
159
186
 
160
187
  # codesign -dv 在成功时返回非零退出码,但输出到 stderr
161
188
  if "adhoc" in result.stderr.lower() or "signed" in result.stderr.lower():
@@ -197,6 +224,8 @@ class MacOSCodeSigner:
197
224
  [codesign_path],
198
225
  capture_output=True,
199
226
  text=True,
227
+ encoding=get_subprocess_encoding(),
228
+ errors='replace',
200
229
  check=False,
201
230
  timeout=10,
202
231
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unifypy
3
- Version: 2.0.8
3
+ Version: 2.0.9
4
4
  Summary: UnifyPy 2.0 - Cross-platform Python app packaging tool
5
5
  Author: Junsen Huang
6
6
  License: MIT License
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes