forked from speedypotato/Pico-Game-Controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_config_tool.ps1
More file actions
76 lines (68 loc) · 2.19 KB
/
Copy pathrun_config_tool.ps1
File metadata and controls
76 lines (68 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Run the Pico IIDX config tool (tools/effect_selector.py) using a Python virtual environment
[CmdletBinding()]
param(
[switch]$SkipInstall
)
$ErrorActionPreference = 'Stop'
$RepoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$VenvPath = Join-Path $RepoRoot '.venv'
$ActivatePs = Join-Path $VenvPath 'Scripts/Activate.ps1'
$PyExe = Join-Path $VenvPath 'Scripts/python.exe'
$ReqFile = Join-Path $RepoRoot 'tools/requirements.txt'
$AppFile = Join-Path $RepoRoot 'tools/effect_selector.py'
${ExeOneFile} = Join-Path $RepoRoot 'dist/PicoGameConfig.exe'
${ExeOneDir} = Join-Path $RepoRoot 'dist/PicoGameConfig/PicoGameConfig.exe'
Write-Host "Repo: $RepoRoot"
# If a compilado EXE exists, run it directly
if (Test-Path ${ExeOneFile}) {
Write-Host "Ejecutando binario empaquetado: ${ExeOneFile}"
& ${ExeOneFile}
return
}
elseif (Test-Path ${ExeOneDir}) {
Write-Host "Ejecutando binario empaquetado: ${ExeOneDir}"
& ${ExeOneDir}
return
}
# Pick Python launcher (python or py -3)
$PythonLauncher = $null
if (Get-Command python -ErrorAction SilentlyContinue) {
$PythonLauncher = 'python'
} elseif (Get-Command py -ErrorAction SilentlyContinue) {
$PythonLauncher = 'py -3'
} else {
Write-Error 'Python no está en PATH. Instálalo y vuelve a intentar.'
}
# Create venv if missing
if (-not (Test-Path $VenvPath)) {
Write-Host "Creando entorno virtual en $VenvPath ..."
& $PythonLauncher -m venv $VenvPath
}
# Try activating the venv; if blocked by policy, fall back to using the venv's python directly
$Activated = $false
try {
Write-Host 'Activando entorno virtual...'
. $ActivatePs
$Activated = $true
}
catch {
Write-Warning 'No se pudo activar el venv (posible ExecutionPolicy). Continuando con el ejecutable del venv directamente.'
}
# Install requirements unless skipped
if (-not $SkipInstall -and (Test-Path $ReqFile)) {
Write-Host "Instalando dependencias desde $ReqFile ..."
if ($Activated) {
pip install -r $ReqFile
}
else {
& $PyExe -m pip install -r $ReqFile
}
}
# Launch the app
Write-Host 'Ejecutando herramienta de configuración...'
if ($Activated) {
python $AppFile
}
else {
& $PyExe $AppFile
}