feat: add Windows setup script and launcher for running from source
- setup-windows.ps1: downloads libmpv DLL and ffmpeg, installs pip deps - 8cut.bat: double-click launcher - main.py: add_dll_directory for libmpv next to script (not just frozen) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,13 +24,12 @@ from PyQt6.QtWidgets import (
|
||||
)
|
||||
from PyQt6.QtCore import Qt, QObject, QThread, QTimer, QRect, QSize, pyqtSignal, QSettings
|
||||
from PyQt6.QtGui import QPainter, QColor, QPen, QPixmap, QDragEnterEvent, QDropEvent, QCursor, QFont, QKeySequence, QShortcut
|
||||
if getattr(sys, "frozen", False):
|
||||
# In frozen builds, help ctypes find bundled libmpv
|
||||
_bundle = Path(sys._MEIPASS)
|
||||
if sys.platform == "win32":
|
||||
os.add_dll_directory(str(_bundle))
|
||||
elif sys.platform == "darwin":
|
||||
os.environ.setdefault("DYLD_LIBRARY_PATH", str(_bundle))
|
||||
if sys.platform == "win32":
|
||||
# Help ctypes find libmpv-2.dll next to main.py or in frozen bundle
|
||||
_dll_dir = Path(sys._MEIPASS) if getattr(sys, "frozen", False) else Path(__file__).parent
|
||||
os.add_dll_directory(str(_dll_dir))
|
||||
elif sys.platform == "darwin" and getattr(sys, "frozen", False):
|
||||
os.environ.setdefault("DYLD_LIBRARY_PATH", str(Path(sys._MEIPASS)))
|
||||
import mpv
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
# 8-cut Windows setup script
|
||||
# Run once: powershell -ExecutionPolicy Bypass -File setup-windows.ps1
|
||||
#
|
||||
# Prerequisites: Python 3.10+ must be installed and on PATH
|
||||
# https://www.python.org/downloads/
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
|
||||
Write-Host "=== 8-cut Windows Setup ===" -ForegroundColor Cyan
|
||||
|
||||
# ── Python deps ────────────────────────────────────────────
|
||||
Write-Host "`nInstalling Python dependencies..."
|
||||
pip install PyQt6 python-mpv
|
||||
|
||||
# ── libmpv ─────────────────────────────────────────────────
|
||||
$mpvDll = Join-Path $root "libmpv-2.dll"
|
||||
if (Test-Path $mpvDll) {
|
||||
Write-Host "`nlibmpv-2.dll already present, skipping." -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "`nDownloading libmpv..."
|
||||
$release = Invoke-RestMethod "https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/latest"
|
||||
$asset = $release.assets | Where-Object { $_.name -like "mpv-dev-x86_64-v3-*" } | Select-Object -First 1
|
||||
$tmpFile = Join-Path $root "mpv-dev.7z"
|
||||
Invoke-WebRequest $asset.browser_download_url -OutFile $tmpFile
|
||||
7z x $tmpFile -o"$root\mpv-dev" -y | Out-Null
|
||||
Copy-Item "$root\mpv-dev\libmpv-2.dll" $root
|
||||
Remove-Item $tmpFile -Force
|
||||
Remove-Item "$root\mpv-dev" -Recurse -Force
|
||||
Write-Host "libmpv-2.dll downloaded." -ForegroundColor Green
|
||||
}
|
||||
|
||||
# ── ffmpeg ─────────────────────────────────────────────────
|
||||
$ffmpeg = Join-Path $root "ffmpeg.exe"
|
||||
if (Test-Path $ffmpeg) {
|
||||
Write-Host "`nffmpeg.exe already present, skipping." -ForegroundColor Green
|
||||
} else {
|
||||
# Check if ffmpeg is on PATH
|
||||
$onPath = Get-Command ffmpeg -ErrorAction SilentlyContinue
|
||||
if ($onPath) {
|
||||
Write-Host "`nffmpeg found on PATH: $($onPath.Source)" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "`nDownloading ffmpeg..."
|
||||
$ffUrl = "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip"
|
||||
$tmpZip = Join-Path $root "ffmpeg.zip"
|
||||
Invoke-WebRequest $ffUrl -OutFile $tmpZip
|
||||
Expand-Archive $tmpZip -DestinationPath "$root\ffmpeg-tmp" -Force
|
||||
$bin = Get-ChildItem -Path "$root\ffmpeg-tmp" -Recurse -Filter ffmpeg.exe | Select-Object -First 1
|
||||
Copy-Item "$($bin.DirectoryName)\ffmpeg.exe" $root
|
||||
Copy-Item "$($bin.DirectoryName)\ffprobe.exe" $root
|
||||
Remove-Item $tmpZip -Force
|
||||
Remove-Item "$root\ffmpeg-tmp" -Recurse -Force
|
||||
Write-Host "ffmpeg.exe downloaded." -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "`n=== Setup complete ===" -ForegroundColor Cyan
|
||||
Write-Host "Run 8-cut with: python main.py"
|
||||
Write-Host "Or double-click: 8cut.bat"
|
||||
Reference in New Issue
Block a user