Trình chạy
----------
Cả hai lệnh trong README đều không chạy được từ một thư mục checkout tên
khác `cowork_local`:
python -m cowork_local -> No module named cowork_local
python __main__.py -> ModuleNotFoundError: No module named 'cowork_local'
Không sửa được bằng mẹo sys.path, vì `state.py` khởi động máy chủ MCP MS365
bằng tiến trình con `python -m cowork_local.mcp_servers.ms365_server` — tiến
trình con cũng phải import được. Hai script tạo một junction ở
`%LOCALAPPDATA%\CoworkLocal\launcher` thay vì bắt người dùng đổi tên thư mục
làm việc.
Môi trường ảo đặt ở `%LOCALAPPDATA%\CoworkLocal\venv`, cố ý KHÔNG đặt trong
repo: các cổng chất lượng quét toàn bộ cây thư mục chứ không đọc
`.gitignore`, nên một `.venv` ở đây sẽ biến vài nghìn module thư viện thành
"mã production không ai import" và làm Gate O đỏ.
requirements.txt
----------------
Chạy thử `run.bat` trên một profile trắng thì app chết ngay lúc mở:
presentation/folder/code_editor.py:41
ModuleNotFoundError: No module named 'pygments'
Quét toàn bộ import bên thứ ba thì thiếu 8 thư viện, trong đó `pygments` và
`pydantic` là bắt buộc — import không có try/except, nên triệu chứng không
phải "tính năng đó không chạy" mà là app không mở được. Nghĩa là cài đúng
theo requirements.txt xong app vẫn hỏng.
Đã tách rõ nhóm bắt buộc / tuỳ chọn kèm lý do từng dòng.
`opendataloader-pdf` để nguyên dạng chú thích vì code tự cài khi cần qua
`core/deps.py::ensure_module`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
113 lines
3.8 KiB
Batchfile
113 lines
3.8 KiB
Batchfile
@echo off
|
|
rem ===========================================================================
|
|
rem Cowork-Local BamBOO - chay ung dung
|
|
rem
|
|
rem Bam dup vao file nay la xong.
|
|
rem
|
|
rem Lan dau tien phai chay install.bat truoc.
|
|
rem
|
|
rem Tham so truyen vao duoc chuyen thang cho QApplication (xem app.py::run),
|
|
rem nen dung duoc cac co cua Qt, vi du: run.bat -style Fusion
|
|
rem ===========================================================================
|
|
setlocal EnableExtensions EnableDelayedExpansion
|
|
chcp 65001 >nul 2>&1
|
|
title Cowork-Local BamBOO
|
|
|
|
set "REPO=%~dp0"
|
|
set "REPO=%REPO:~0,-1%"
|
|
set "APPHOME=%LOCALAPPDATA%\CoworkLocal"
|
|
set "VENV=%APPHOME%\venv"
|
|
set "LAUNCHER=%APPHOME%\launcher"
|
|
|
|
rem --------------------------------------------------------------------------
|
|
rem 1. Chon trinh thong dich
|
|
rem
|
|
rem Uu tien moi truong ao do install.bat dung. Khong co thi quay ve Python cua
|
|
rem he thong — nguoi dung co the da chay "install.bat --system".
|
|
rem --------------------------------------------------------------------------
|
|
rem Duong dan luon duoc boc trong dau nhay: %LOCALAPPDATA% co the chua khoang
|
|
rem trang neu ten dang nhap co khoang trang.
|
|
if exist "%VENV%\Scripts\python.exe" (
|
|
set "RUNPY="%VENV%\Scripts\python.exe""
|
|
) else (
|
|
set "RUNPY="
|
|
for /f "delims=" %%P in ('where py 2^>nul') do if not defined RUNPY set "RUNPY="%%P" -3"
|
|
if not defined RUNPY (
|
|
for /f "delims=" %%P in ('where python 2^>nul') do if not defined RUNPY set "RUNPY="%%P""
|
|
)
|
|
)
|
|
|
|
if not defined RUNPY (
|
|
echo.
|
|
echo [LỖI] Không tìm thấy Python. Chạy install.bat trước đã.
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
rem Chua co moi truong ao thi kiem xem Python he thong co du thu vien khong.
|
|
rem Khong kiem thi nguoi dung chi nhan duoc mot ModuleNotFoundError tho, chang
|
|
rem biet la phai chay install.bat.
|
|
if not exist "%VENV%\Scripts\python.exe" (
|
|
!RUNPY! -c "import PySide6" >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo.
|
|
echo [LỖI] Thư viện chưa được cài. Chạy install.bat trước đã.
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
rem --------------------------------------------------------------------------
|
|
rem 2. Duong dan de import duoc goi "cowork_local"
|
|
rem
|
|
rem Thu muc ma nguon phai mang dung ten "cowork_local" thi Python moi import
|
|
rem duoc no. Neu khong, install.bat da tao mot junction; o day chi kiem tra va
|
|
rem tu dung lai neu no bi xoa — de nguoi dung khong phai chay lai install.bat
|
|
rem chi vi mot thu muc tam bi don.
|
|
rem --------------------------------------------------------------------------
|
|
for %%I in ("%REPO%") do set "REPO_NAME=%%~nxI"
|
|
if /I "%REPO_NAME%"=="cowork_local" (
|
|
for %%I in ("%REPO%\..") do set "PKGPATH=%%~fI"
|
|
) else (
|
|
if not exist "%LAUNCHER%\cowork_local" (
|
|
if not exist "%LAUNCHER%" mkdir "%LAUNCHER%" >nul 2>&1
|
|
mklink /J "%LAUNCHER%\cowork_local" "%REPO%" >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo.
|
|
echo [LỖI] Không tạo được liên kết thư mục. Chạy install.bat lại.
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
)
|
|
set "PKGPATH=%LAUNCHER%"
|
|
)
|
|
|
|
rem --------------------------------------------------------------------------
|
|
rem 3. Chay
|
|
rem
|
|
rem Dat thu muc lam viec o goc ma nguon va PYTHONPATH tro toi thu muc CHA cua
|
|
rem goi — dung cach CI dang chay (.gitea/workflows/ci.yaml). Tien trinh con
|
|
rem (may chu MCP MS365) thua ke PYTHONPATH nay nen cung import duoc.
|
|
rem --------------------------------------------------------------------------
|
|
if defined PYTHONPATH (
|
|
set "PYTHONPATH=!PKGPATH!;%PYTHONPATH%"
|
|
) else (
|
|
set "PYTHONPATH=!PKGPATH!"
|
|
)
|
|
set "PYTHONIOENCODING=utf-8"
|
|
cd /d "%REPO%"
|
|
|
|
!RUNPY! -m cowork_local %*
|
|
set "RC=%ERRORLEVEL%"
|
|
|
|
if not "%RC%"=="0" (
|
|
echo.
|
|
echo Ứng dụng thoát với mã lỗi %RC%. Xem thông báo ở trên.
|
|
echo.
|
|
pause
|
|
)
|
|
exit /b %RC%
|