From 2d2c87d505ad7baacd658d37ef4a72baf72e280e Mon Sep 17 00:00:00 2001 From: root Date: Wed, 29 Apr 2026 11:00:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20build=5Flinux.sh=20=E6=B7=BB=E5=8A=A0=20?= =?UTF-8?q?venv=20=E9=99=8D=E7=BA=A7=E6=9C=BA=E5=88=B6=EF=BC=8C=E9=80=82?= =?UTF-8?q?=E9=85=8D=E6=97=A0=20python3-venv=20=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/build_linux.sh | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/build/build_linux.sh b/build/build_linux.sh index 86e035a..ac2a71e 100755 --- a/build/build_linux.sh +++ b/build/build_linux.sh @@ -12,12 +12,27 @@ if ! command -v python3 &> /dev/null; then echo "Error: python3 not found"; exit 1 fi -VENV_DIR="$PROJECT_ROOT/.venv_build" -echo "Creating virtual environment: $VENV_DIR" -python3 -m venv "$VENV_DIR" -source "$VENV_DIR/bin/activate" -pip install --upgrade pip -pip install -r requirements.txt +# ── 尝试 venv 隔离构建,失败则用系统环境 ── +USE_VENV=false +if python3 -m venv --help &>/dev/null; then + VENV_DIR="$PROJECT_ROOT/.venv_build" + if python3 -m venv "$VENV_DIR" 2>/dev/null; then + source "$VENV_DIR/bin/activate" + USE_VENV=true + echo "Using virtual environment" + pip install --upgrade pip -q + pip install -r requirements.txt -q + else + echo "Warning: venv creation failed, falling back to system Python" + fi +else + echo "Warning: python3-venv not available, falling back to system Python" +fi + +if [ "$USE_VENV" = false ]; then + pip install -r requirements.txt --break-system-packages -q 2>/dev/null || \ + pip install -r requirements.txt -q 2>/dev/null || true +fi echo "Cleaning previous builds..." rm -rf dist/ build/trulymem/ 2>/dev/null || true @@ -25,13 +40,15 @@ rm -rf dist/ build/trulymem/ 2>/dev/null || true echo "================================" echo "Building TrulyMEM (TUI + Web embedded)" echo "================================" -python -m PyInstaller --clean build/trulymem.spec --noconfirm +python3 -m PyInstaller --clean build/trulymem.spec --noconfirm echo "================================" echo "===== Build Complete =====" echo "Binary: dist/TrulyMEM" ls -la dist/ -deactivate -rm -rf "$VENV_DIR" +if [ "$USE_VENV" = true ]; then + deactivate 2>/dev/null || true + rm -rf "$VENV_DIR" +fi echo "Build finished successfully!" \ No newline at end of file