mirror of
https://gitcode.com/JianFeeeee/TrulyMEM-TrueHumanMEM.git
synced 2026-10-15 12:15:32 +00:00
fix: 修复Linux和macOS打包脚本,添加虚拟环境支持
- 在打包过程中自动创建和激活虚拟环境
- 在虚拟环境中安装依赖,避免系统环境污染
- 打包完成后自动清理虚拟环境
- 统一使用python命令而非python3
🤖 Generated with CodeArts Agent
This commit is contained in:
25
build/build_linux.sh
Normal file → Executable file
25
build/build_linux.sh
Normal file → Executable file
@ -14,14 +14,26 @@ if ! command -v python3 &> /dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Installing dependencies..."
|
# 创建并激活虚拟环境
|
||||||
pip3 install -r requirements.txt 2>/dev/null || pip install -r requirements.txt
|
VENV_DIR="$PROJECT_ROOT/.venv_build"
|
||||||
|
|
||||||
|
echo "Creating virtual environment: $VENV_DIR"
|
||||||
|
python3 -m venv "$VENV_DIR"
|
||||||
|
|
||||||
|
echo "Activating virtual environment..."
|
||||||
|
source "$VENV_DIR/bin/activate"
|
||||||
|
|
||||||
|
echo "Upgrading pip in virtual environment..."
|
||||||
|
pip install --upgrade pip
|
||||||
|
|
||||||
|
echo "Installing dependencies in virtual environment..."
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
echo "Cleaning previous builds..."
|
echo "Cleaning previous builds..."
|
||||||
rm -rf build/dist build/__pycache__ 2>/dev/null || true
|
rm -rf build/dist build/__pycache__ 2>/dev/null || true
|
||||||
|
|
||||||
echo "Running PyInstaller..."
|
echo "Running PyInstaller..."
|
||||||
python3 -m PyInstaller trulymem_entry.py \
|
python -m PyInstaller trulymem_entry.py \
|
||||||
--clean \
|
--clean \
|
||||||
--onefile \
|
--onefile \
|
||||||
--console \
|
--console \
|
||||||
@ -62,3 +74,10 @@ python3 -m PyInstaller trulymem_entry.py \
|
|||||||
echo "===== Build Complete ====="
|
echo "===== Build Complete ====="
|
||||||
echo "Binary: dist/TrulyMEM"
|
echo "Binary: dist/TrulyMEM"
|
||||||
ls -la dist/
|
ls -la dist/
|
||||||
|
|
||||||
|
# 清理虚拟环境
|
||||||
|
echo "Cleaning up virtual environment..."
|
||||||
|
deactivate
|
||||||
|
rm -rf "$VENV_DIR"
|
||||||
|
|
||||||
|
echo "Build finished successfully!"
|
||||||
@ -14,8 +14,20 @@ if ! command -v python3 &> /dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Installing dependencies..."
|
# 创建并激活虚拟环境
|
||||||
pip3 install -r requirements.txt
|
VENV_DIR="$PROJECT_ROOT/.venv_build"
|
||||||
|
|
||||||
|
echo "Creating virtual environment: $VENV_DIR"
|
||||||
|
python3 -m venv "$VENV_DIR"
|
||||||
|
|
||||||
|
echo "Activating virtual environment..."
|
||||||
|
source "$VENV_DIR/bin/activate"
|
||||||
|
|
||||||
|
echo "Upgrading pip in virtual environment..."
|
||||||
|
pip install --upgrade pip
|
||||||
|
|
||||||
|
echo "Installing dependencies in virtual environment..."
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
echo "Generating ICNS icon..."
|
echo "Generating ICNS icon..."
|
||||||
if [ -d "pic/TrulyMEM.iconset" ]; then
|
if [ -d "pic/TrulyMEM.iconset" ]; then
|
||||||
@ -27,7 +39,7 @@ echo "Cleaning previous builds..."
|
|||||||
rm -rf build/dist build/__pycache__ 2>/dev/null || true
|
rm -rf build/dist build/__pycache__ 2>/dev/null || true
|
||||||
|
|
||||||
echo "Running PyInstaller..."
|
echo "Running PyInstaller..."
|
||||||
python3 -m PyInstaller trulymem_entry.py \
|
python -m PyInstaller trulymem_entry.py \
|
||||||
--clean \
|
--clean \
|
||||||
--onefile \
|
--onefile \
|
||||||
--console \
|
--console \
|
||||||
@ -69,3 +81,10 @@ python3 -m PyInstaller trulymem_entry.py \
|
|||||||
echo "===== Build Complete ====="
|
echo "===== Build Complete ====="
|
||||||
echo "Binary: dist/TrulyMEM"
|
echo "Binary: dist/TrulyMEM"
|
||||||
ls -la dist/
|
ls -la dist/
|
||||||
|
|
||||||
|
# 清理虚拟环境
|
||||||
|
echo "Cleaning up virtual environment..."
|
||||||
|
deactivate
|
||||||
|
rm -rf "$VENV_DIR"
|
||||||
|
|
||||||
|
echo "Build finished successfully!"
|
||||||
Reference in New Issue
Block a user