Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dist/
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
.upx/

# Dev settings
settings.toml
16 changes: 9 additions & 7 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

& "$PSScriptRoot/compile_resources.ps1"

$ProjectRoot = "$PSScriptRoot/.."
$SupportsSplashScreen = [System.Convert]::ToBoolean($(uv run --active python -c "import _tkinter; print(hasattr(_tkinter, '__file__'))"))

$arguments = @(
"$PSScriptRoot/../src/AutoSplit.py",
"$ProjectRoot/src/AutoSplit.py",
'--onefile',
'--windowed',
'--additional-hooks-dir=Pyinstaller/hooks',
'--optimize 2', # Remove asserts and docstrings for smaller build
"--add-data=pyproject.toml$([System.IO.Path]::PathSeparator).",
'--icon=res/icon.ico')
"--additional-hooks-dir=$ProjectRoot/Pyinstaller/hooks",
"--add-data=$ProjectRoot/pyproject.toml$([System.IO.Path]::PathSeparator).",
"--upx-dir=$PSScriptRoot/.upx"
"--icon=$ProjectRoot/res/icon.ico")
if ($SupportsSplashScreen) {
# https://github.com/pyinstaller/pyinstaller/issues/9022
$arguments += @('--splash=res/splash.png')
$arguments += @("--splash=$ProjectRoot/res/splash.png")
}
if ($IsWindows) {
$arguments += @(
Expand All @@ -25,10 +27,10 @@ if ($IsWindows) {
Start-Process -Wait -NoNewWindow uv -ArgumentList $(@('run', '--active', 'pyinstaller') + $arguments)

If ($IsLinux) {
Move-Item -Force $PSScriptRoot/../dist/AutoSplit $PSScriptRoot/../dist/AutoSplit.elf
Move-Item -Force $ProjectRoot/dist/AutoSplit $ProjectRoot/dist/AutoSplit.elf
If ($?) {
Write-Host 'Added .elf extension'
}
chmod +x $PSScriptRoot/../dist/AutoSplit.elf
chmod +x $ProjectRoot/dist/AutoSplit.elf
Write-Host 'Added execute permission'
}
19 changes: 17 additions & 2 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If ($IsLinux) {
}
}

# Installing Python dependencies
# Installing system dependencies
If ($IsLinux) {
If (-not $Env:GITHUB_JOB -or $Env:GITHUB_JOB -eq 'Build') {
sudo apt-get update
Expand All @@ -38,8 +38,23 @@ If ($IsLinux) {
}
}

# UPX is only used by PyInstaller on Windows
If ($IsWindows -and [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq 'X64') {
$UPXVersion = '5.0.1'
$UPXFolderName = "upx-$UPXVersion-win64"
Write-Output "Installing $UPXFolderName"
if (Test-Path "$PSScriptRoot/.upx") { Remove-Item $PSScriptRoot/.upx -Recurse }
Invoke-WebRequest `
-Uri https://github.com/upx/upx/releases/download/v$UPXVersion/$UPXFolderName.zip `
-OutFile $Env:TEMP/$UPXFolderName.zip
# Automatically install in a local untracked folder. This makes it easy to version and replicate on CI
Expand-Archive $Env:TEMP/$UPXFolderName.zip $PSScriptRoot/.upx
Move-Item $PSScriptRoot/.upx/$UPXFolderName/* $PSScriptRoot/.upx
Remove-Item $PSScriptRoot/.upx/$UPXFolderName
}

$prod = If ($Env:GITHUB_JOB -eq 'Build') { '--no-dev' } Else { }
$lock = If ($Env:GITHUB_JOB) { '--locked' } Else { '--upgrade' }
$lock = If ($Env:GITHUB_JOB) { '--locked' } Else { }
Write-Output "Installing Python dependencies with: uv sync $prod $lock"
uv sync --active $prod $lock

Expand Down