mirror of
https://github.com/Minidoracat/mcp-feedback-enhanced.git
synced 2025-07-27 02:22:26 +08:00
Merge pull request #93 from Alsan/main
feat: 新增 macOS PyO3 編譯配置支援 - 新增 .cargo/config.toml 配置 macOS 鏈接器參數 - 支援 Intel (x86_64) 和 Apple Silicon (aarch64) 架構 - 解決 macOS 上 PyO3 undefined dynamic_lookup 編譯問題 - 遵循 PyO3 官方推薦的 macOS 配置最佳實踐 感謝 @Alsan 的寶貴貢獻!這將大大改善 macOS 用戶的開發體驗。
This commit is contained in:
commit
5b407061af
11
src-tauri/.cargo/config.toml
Normal file
11
src-tauri/.cargo/config.toml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[target.x86_64-apple-darwin]
|
||||||
|
rustflags = [
|
||||||
|
"-C", "link-arg=-undefined",
|
||||||
|
"-C", "link-arg=dynamic_lookup",
|
||||||
|
]
|
||||||
|
|
||||||
|
[target.aarch64-apple-darwin]
|
||||||
|
rustflags = [
|
||||||
|
"-C", "link-arg=-undefined",
|
||||||
|
"-C", "link-arg=dynamic_lookup",
|
||||||
|
]
|
@ -19,10 +19,7 @@ try:
|
|||||||
from mcp_feedback_enhanced.debug import server_debug_log as debug_log
|
from mcp_feedback_enhanced.debug import server_debug_log as debug_log
|
||||||
from mcp_feedback_enhanced.web.main import WebUIManager, get_web_ui_manager
|
from mcp_feedback_enhanced.web.main import WebUIManager, get_web_ui_manager
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
# 在這裡無法使用 debug_log,因為導入失敗
|
print(f"無法導入 MCP Feedback Enhanced 模組: {e}")
|
||||||
import sys
|
|
||||||
|
|
||||||
sys.stderr.write(f"無法導入 MCP Feedback Enhanced 模組: {e}\n")
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@ -70,8 +67,8 @@ class DesktopApp:
|
|||||||
self.web_manager.start_server()
|
self.web_manager.start_server()
|
||||||
|
|
||||||
# 等待服務器啟動
|
# 等待服務器啟動
|
||||||
max_wait = 10.0 # 最多等待 10 秒
|
max_wait = 10 # 最多等待 10 秒
|
||||||
wait_count = 0.0
|
wait_count = 0
|
||||||
while wait_count < max_wait:
|
while wait_count < max_wait:
|
||||||
if (
|
if (
|
||||||
self.web_manager.server_thread
|
self.web_manager.server_thread
|
||||||
@ -115,24 +112,15 @@ class DesktopApp:
|
|||||||
# 找到 Tauri 可執行檔案
|
# 找到 Tauri 可執行檔案
|
||||||
# 首先嘗試從打包後的位置找(PyPI 安裝後的位置)
|
# 首先嘗試從打包後的位置找(PyPI 安裝後的位置)
|
||||||
try:
|
try:
|
||||||
debug_log("嘗試從發布包位置導入桌面模組...")
|
|
||||||
from mcp_feedback_enhanced.desktop_release import __file__ as desktop_init
|
from mcp_feedback_enhanced.desktop_release import __file__ as desktop_init
|
||||||
|
|
||||||
desktop_dir = Path(desktop_init).parent
|
desktop_dir = Path(desktop_init).parent
|
||||||
debug_log(f"桌面應用目錄: {desktop_dir}")
|
|
||||||
|
|
||||||
# 列出目錄內容以便調試
|
|
||||||
if desktop_dir.exists():
|
|
||||||
debug_log(f"桌面目錄內容: {list(desktop_dir.iterdir())}")
|
|
||||||
else:
|
|
||||||
debug_log(f"桌面目錄不存在: {desktop_dir}")
|
|
||||||
|
|
||||||
# 根據平台選擇對應的二進制文件
|
# 根據平台選擇對應的二進制文件
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
system = platform.system().lower()
|
system = platform.system().lower()
|
||||||
machine = platform.machine().lower()
|
machine = platform.machine().lower()
|
||||||
debug_log(f"檢測到平台: {system}, 架構: {machine}")
|
|
||||||
|
|
||||||
# 定義平台到二進制文件的映射
|
# 定義平台到二進制文件的映射
|
||||||
if system == "windows":
|
if system == "windows":
|
||||||
@ -153,17 +141,9 @@ class DesktopApp:
|
|||||||
# 回退到通用名稱
|
# 回退到通用名稱
|
||||||
tauri_exe = desktop_dir / "mcp-feedback-enhanced-desktop"
|
tauri_exe = desktop_dir / "mcp-feedback-enhanced-desktop"
|
||||||
|
|
||||||
debug_log(f"預期的可執行檔案路徑: {tauri_exe}")
|
|
||||||
|
|
||||||
if tauri_exe.exists():
|
if tauri_exe.exists():
|
||||||
debug_log(f"找到打包後的 Tauri 可執行檔案: {tauri_exe}")
|
debug_log(f"找到打包後的 Tauri 可執行檔案: {tauri_exe}")
|
||||||
# 檢查文件權限
|
|
||||||
file_stat = tauri_exe.stat()
|
|
||||||
debug_log(
|
|
||||||
f"文件權限: {oct(file_stat.st_mode)}, 大小: {file_stat.st_size} bytes"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
debug_log(f"主要可執行檔案不存在: {tauri_exe}")
|
|
||||||
# 嘗試回退選項
|
# 嘗試回退選項
|
||||||
fallback_files = [
|
fallback_files = [
|
||||||
desktop_dir / "mcp-feedback-enhanced-desktop.exe",
|
desktop_dir / "mcp-feedback-enhanced-desktop.exe",
|
||||||
@ -173,9 +153,7 @@ class DesktopApp:
|
|||||||
desktop_dir / "mcp-feedback-enhanced-desktop",
|
desktop_dir / "mcp-feedback-enhanced-desktop",
|
||||||
]
|
]
|
||||||
|
|
||||||
debug_log("嘗試回退選項...")
|
|
||||||
for fallback in fallback_files:
|
for fallback in fallback_files:
|
||||||
debug_log(f"檢查回退文件: {fallback} - 存在: {fallback.exists()}")
|
|
||||||
if fallback.exists():
|
if fallback.exists():
|
||||||
tauri_exe = fallback
|
tauri_exe = fallback
|
||||||
debug_log(f"使用回退的可執行檔案: {tauri_exe}")
|
debug_log(f"使用回退的可執行檔案: {tauri_exe}")
|
||||||
@ -185,8 +163,7 @@ class DesktopApp:
|
|||||||
f"找不到任何可執行檔案,檢查的路徑: {tauri_exe}"
|
f"找不到任何可執行檔案,檢查的路徑: {tauri_exe}"
|
||||||
)
|
)
|
||||||
|
|
||||||
except (ImportError, FileNotFoundError) as e:
|
except (ImportError, FileNotFoundError):
|
||||||
debug_log(f"從發布包位置導入失敗: {e}")
|
|
||||||
# 回退到開發環境路徑
|
# 回退到開發環境路徑
|
||||||
debug_log("未找到打包後的可執行檔案,嘗試開發環境路徑...")
|
debug_log("未找到打包後的可執行檔案,嘗試開發環境路徑...")
|
||||||
project_root = Path(__file__).parent.parent.parent.parent
|
project_root = Path(__file__).parent.parent.parent.parent
|
||||||
@ -349,7 +326,7 @@ def run_desktop_app():
|
|||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug_log(f"桌面應用程式運行失敗: {e}")
|
print(f"桌面應用程式運行失敗: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user