| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- # Set error handling
- $ErrorActionPreference = "Stop"
- # Get the root directory and third_party directory
- $ROOT_DIR = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent | Split-Path -Parent | Split-Path -Parent -Resolve
- # Include the common functions
- . "$ROOT_DIR/hack/lib/windows/init.ps1"
- function Install-Dependency {
- pip install uv
- if ($LASTEXITCODE -ne 0) {
- GPUStack.Log.Fatal "failed to install uv."
- }
- uv sync
- if ($LASTEXITCODE -ne 0) {
- GPUStack.Log.Fatal "failed run uv sync."
- }
- uv run pre-commit install
- if ($LASTEXITCODE -ne 0) {
- GPUStack.Log.Fatal "failed run pre-commint install."
- }
- }
- function Get-UI {
- $defaultTag = "latest"
- $uiPath = Join-Path -Path $ROOT_DIR -ChildPath "gpustack/ui"
- $tmpPath = Join-Path -Path $uiPath -ChildPath "tmp"
- $tmpUIPath = Join-Path -Path $tmpPath -ChildPath "ui"
- $tag = "latest"
- if ($GIT_VERSION -ne "v0.0.0") {
- $tag = $GIT_VERSION
- }
- $null = Remove-Item -Recurse -Force $uiPath -ErrorAction Ignore
- $null = New-Item -ItemType Directory -Path $tmpUIPath
- GPUStack.Log.Info "downloading '$tag' UI assets"
- try {
- $tmpFile = "$tmpPath/ui.tar.gz"
- $url = "https://gpustack-ui-1303613262.cos.accelerate.myqcloud.com/releases/$tag.tar.gz"
- DownloadWithRetries -url $url -outFile $tmpFile -maxRetries 3
- # For git action's bug, can't use tar directly.
- # https://github.com/julia-actions/setup-julia/issues/205
- & "$env:WINDIR/System32/tar" -xzf "$tmpPath/ui.tar.gz" -C "$tmpUIPath"
- }
- catch {
- GPUStack.Log.Fatal "failed to download '$tag' UI archive: $($_.Exception.Message)"
- if (-eq $tag $defaultTag) {
- return
- }
- GPUStack.Log.Warn "failed to download '$tag' UI archive, fallback to '$defaultTag' UI archive"
- try {
- $tmpFile = "$tmpPath/ui.tar.gz"
- $url = "https://gpustack-ui-1303613262.cos.accelerate.myqcloud.com/releases/$defaultTag.tar.gz"
- DownloadWithRetries -url $url -outFile $tmpFile -maxRetries 3
- tar -xzf $tmpFile -C "$tmpUIPath"
- }
- catch {
- GPUStack.Log.Fatal "failed to download '$defaultTag' UI archive: : $($_.Exception.Message)"
- }
- }
- Copy-Item -Path "$tmpUIPath/dist/*" -Destination $uiPath -Recurse
- Remove-Item -Recurse -Force $tmpUIPath -ErrorAction Ignore
- }
- function DownloadWithRetries {
- param (
- [string]$url,
- [string]$outFile,
- [int]$maxRetries = 3
- )
- for ($i = 1; $i -le $maxRetries; $i++) {
- try {
- GPUStack.Log.Info "Attempting to download from $url (Attempt $i of $maxRetries)"
- Invoke-WebRequest -Uri $url -OutFile $outFile -ErrorAction Stop
- return
- }
- catch {
- GPUStack.Log.Warn "Download attempt $i failed: $($_.Exception.Message)"
- if ($i -eq $maxRetries) {
- throw $_
- }
- }
- }
- }
- #
- # main
- #
- GPUStack.Log.Info "+++ DEPENDENCIES +++"
- try {
- Install-Dependency
- Get-UI
- }
- catch {
- GPUStack.Log.Fatal "failed to download dependencies: $($_.Exception.Message)"
- }
- GPUStack.Log.Info "-- DEPENDENCIES ---"
|