Add package data for GPU rent and update CLI documentation
- Added package data configuration for the 'gpu_rent' package in pyproject.toml. - Updated README.md to include usage instructions for Windows and Unix launchers. - Enhanced CLI documentation in cli.md to reflect new commands and their functionalities. - Revised setup.md to clarify installation steps and environment setup. - Improved error handling and command descriptions in the CLI implementation. - Added new functions for model version handling and flavor resolution in the codebase. - Updated state management to include additional properties for better tracking.
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
#Requires -Version 5.1
|
||||
# Windows launcher: venv + pip + python -m gpu_rent. Call via gpu-rent.bat if ExecutionPolicy blocks this file.
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$Root = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
Set-Location -LiteralPath $Root
|
||||
try {
|
||||
$utf8 = New-Object System.Text.UTF8Encoding $false
|
||||
[Console]::OutputEncoding = $utf8
|
||||
$script:OutputEncoding = $utf8
|
||||
} catch {
|
||||
}
|
||||
|
||||
function Test-Python311 {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Exe,
|
||||
[string[]]$Prefix = @()
|
||||
)
|
||||
$cmd = Get-Command $Exe -ErrorAction SilentlyContinue
|
||||
if (-not $cmd) {
|
||||
return $false
|
||||
}
|
||||
try {
|
||||
& $Exe @Prefix -c "import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)" 2>$null | Out-Null
|
||||
return ($LASTEXITCODE -eq 0)
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
$PyExe = $null
|
||||
$PyPrefix = @()
|
||||
$found = $false
|
||||
foreach ($row in @(
|
||||
@{ Exe = "py"; Prefix = @("-3.12") },
|
||||
@{ Exe = "py"; Prefix = @("-3.11") },
|
||||
@{ Exe = "py"; Prefix = @("-3") },
|
||||
@{ Exe = "python3"; Prefix = @() },
|
||||
@{ Exe = "python"; Prefix = @() }
|
||||
)) {
|
||||
if (Test-Python311 -Exe $row.Exe -Prefix $row.Prefix) {
|
||||
$PyExe = $row.Exe
|
||||
$PyPrefix = $row.Prefix
|
||||
$found = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $found) {
|
||||
Write-Host "gpu-rent: нужен Python 3.11+. Поставь с python.org и включи Add python.exe to PATH."
|
||||
exit 1
|
||||
}
|
||||
|
||||
$VenvPy = Join-Path $Root ".venv\Scripts\python.exe"
|
||||
if (-not (Test-Path -LiteralPath $VenvPy)) {
|
||||
Write-Host "gpu-rent: создаю .venv"
|
||||
& $PyExe @PyPrefix -m venv (Join-Path $Root ".venv")
|
||||
}
|
||||
|
||||
$Stamp = Join-Path $Root ".venv\.gpu-rent-installed"
|
||||
$Pyproject = Join-Path $Root "pyproject.toml"
|
||||
$needInstall = -not (Test-Path -LiteralPath $Stamp)
|
||||
if (-not $needInstall -and (Test-Path -LiteralPath $Pyproject)) {
|
||||
$needInstall = (Get-Item -LiteralPath $Pyproject).LastWriteTime -gt (Get-Item -LiteralPath $Stamp).LastWriteTime
|
||||
}
|
||||
if ($needInstall) {
|
||||
Write-Host "gpu-rent: ставлю пакет в .venv"
|
||||
& $VenvPy -m pip install -U pip
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
& $VenvPy -m pip install -e $Root
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
Get-Date -Format o | Set-Content -LiteralPath $Stamp -Encoding ascii
|
||||
}
|
||||
|
||||
$GpuHome = Join-Path $env:USERPROFILE ".gpu-rent"
|
||||
$EnvFile = Join-Path $GpuHome ".env"
|
||||
$Example = Join-Path $Root "env.example"
|
||||
if (-not (Test-Path -LiteralPath $EnvFile)) {
|
||||
New-Item -ItemType Directory -Force -Path $GpuHome | Out-Null
|
||||
if (Test-Path -LiteralPath $Example) {
|
||||
Copy-Item -LiteralPath $Example -Destination $EnvFile
|
||||
Write-Host "gpu-rent: created $EnvFile - fill OS_* (docs/setup.md)"
|
||||
}
|
||||
}
|
||||
|
||||
$ErrorActionPreference = "Continue"
|
||||
& $VenvPy -m gpu_rent @args
|
||||
exit $LASTEXITCODE
|
||||
Reference in New Issue
Block a user