Fix build-appimage.sh: use venv for PyInstaller, set proper paths
- Create venv with --copies to avoid system pip restrictions (PEP 668) - Install deps into venv before PyInstaller run - Use absolute paths for --add-data
This commit is contained in:
parent
81b2ab2173
commit
7a86732953
@ -9,6 +9,7 @@ APP_DIR="$BUILD_DIR/$APP_NAME.AppDir"
|
||||
|
||||
PYTHON="${PYTHON:-python3}"
|
||||
PIP="${PIP:-pip3}"
|
||||
VENV_DIR="$BUILD_DIR/venv"
|
||||
|
||||
ARCH="${ARCH:-x86_64}"
|
||||
APPIMAGE_OUTPUT="$PROJECT_DIR/$APP_NAME-${ARCH}.AppImage"
|
||||
@ -37,9 +38,6 @@ check_deps() {
|
||||
missing+=("$cmd")
|
||||
fi
|
||||
done
|
||||
if ! "$PYTHON" -c "import PyInstaller" 2>/dev/null; then
|
||||
missing+=("pyinstaller (pip install pyinstaller)")
|
||||
fi
|
||||
if [ ${#missing[@]} -gt 0 ]; then
|
||||
err "Missing dependencies: ${missing[*]}"
|
||||
exit 1
|
||||
@ -47,10 +45,15 @@ check_deps() {
|
||||
}
|
||||
|
||||
install_pyinstaller() {
|
||||
if ! "$PYTHON" -c "import PyInstaller" 2>/dev/null; then
|
||||
info "Installing PyInstaller..."
|
||||
"$PIP" install pyinstaller
|
||||
if [ -f "$VENV_DIR/bin/python" ] && "$VENV_DIR/bin/python" -c "import PyInstaller" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
info "Creating virtual environment..."
|
||||
"$PYTHON" -m venv --copies "$VENV_DIR"
|
||||
info "Installing PyInstaller and dependencies..."
|
||||
"$VENV_DIR/bin/pip" install pyinstaller
|
||||
# Install project dependencies for bundling
|
||||
"$VENV_DIR/bin/pip" install -r "$PROJECT_DIR/requirements.txt"
|
||||
}
|
||||
|
||||
download_appimagetool() {
|
||||
@ -73,14 +76,14 @@ build_appdir() {
|
||||
|
||||
info "Running PyInstaller..."
|
||||
cd "$PROJECT_DIR"
|
||||
"$PYTHON" -m PyInstaller \
|
||||
"$VENV_DIR/bin/pyinstaller" \
|
||||
--onedir \
|
||||
--name "$APP_NAME" \
|
||||
--distpath "$APP_DIR/usr/bin" \
|
||||
--workpath "$BUILD_DIR/pybuild" \
|
||||
--specpath "$BUILD_DIR" \
|
||||
--add-data "src:src" \
|
||||
--paths src \
|
||||
--add-data "$PROJECT_DIR/src:$APP_NAME/src" \
|
||||
--paths "$PROJECT_DIR/src" \
|
||||
--hidden-import PyQt6.QtMultimedia \
|
||||
--hidden-import PyQt6.QtMultimediaWidgets \
|
||||
--collect-all PyQt6 \
|
||||
@ -123,11 +126,13 @@ APPRUN
|
||||
}
|
||||
|
||||
create_icon() {
|
||||
# Generate a simple SVG icon or use a placeholder
|
||||
local icon="$APP_DIR/$APP_NAME.png"
|
||||
# Create a minimal 256x256 PNG using Python + Pillow if available
|
||||
if "$PYTHON" -c "from PIL import Image" 2>/dev/null; then
|
||||
"$PYTHON" -c "
|
||||
local py="$VENV_DIR/bin/python3"
|
||||
if [ ! -f "$py" ]; then
|
||||
py="$PYTHON"
|
||||
fi
|
||||
if "$py" -c "from PIL import Image" 2>/dev/null; then
|
||||
"$py" -c "
|
||||
from PIL import Image, ImageDraw
|
||||
img = Image.new('RGBA', (256, 256), (0, 0, 0, 0))
|
||||
draw = ImageDraw.Draw(img)
|
||||
@ -170,8 +175,8 @@ main() {
|
||||
echo -e "${CYAN}========================================${NC}"
|
||||
echo ""
|
||||
|
||||
check_deps
|
||||
install_pyinstaller
|
||||
check_deps
|
||||
mkdir -p "$BUILD_DIR"
|
||||
download_appimagetool
|
||||
build_appdir
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user