Repository navigation
Expand file tree
/
Copy pathinstall.ps1
More file actions
140 lines (129 loc) · 6.39 KB
/
Copy pathinstall.ps1
File metadata and controls
140 lines (129 loc) · 6.39 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Intel Arc Models Runner - Automated Windows Installer
# Usage: .\install.bat (works when PowerShell script execution is restricted)
# .\install.ps1 (when the current PowerShell policy allows scripts)
$ErrorActionPreference = "Stop"
Write-Host ""
Write-Host "=================================================================" -ForegroundColor Cyan
Write-Host " Intel Arc Models Runner - Automated Windows Setup " -ForegroundColor White
Write-Host " Target Silicon: Intel Arc GPUs & Intel AI Boost NPUs " -ForegroundColor DarkCyan
Write-Host "=================================================================" -ForegroundColor Cyan
Write-Host ""
# 1. Verify Python
Write-Host "[1/4] Checking Python runtime..." -ForegroundColor Yellow
try {
$pythonVersion = python --version 2>&1
Write-Host " Found: $pythonVersion" -ForegroundColor Green
} catch {
Write-Host " ERROR: Python is not installed or not available in PATH." -ForegroundColor Red
Write-Host " Please install Python 3.10+ from https://www.python.org/" -ForegroundColor Yellow
exit 1
}
# 2. Check Pip
Write-Host "[2/4] Checking pip package manager..." -ForegroundColor Yellow
try {
$pipVersion = python -m pip --version 2>&1
Write-Host " Found: $pipVersion" -ForegroundColor Green
} catch {
Write-Host " ERROR: pip is not available." -ForegroundColor Red
exit 1
}
# 3. Install Package
Write-Host "[3/4] Installing Intel Arc Models Runner..." -ForegroundColor Yellow
$pythonScriptsDir = (python -c "import sysconfig; print(sysconfig.get_path('scripts'))").Trim()
if (-not [string]::IsNullOrWhiteSpace($pythonScriptsDir)) {
$pythonScriptsDir = [System.IO.Path]::GetFullPath($pythonScriptsDir)
$processHasScripts = @($env:Path -split ';' | Where-Object {
[string]::Equals($_.TrimEnd('\'), $pythonScriptsDir.TrimEnd('\'), [StringComparison]::OrdinalIgnoreCase)
})
if ($processHasScripts.Count -eq 0) {
$env:Path = "$env:Path;$pythonScriptsDir"
}
}
$pipBootstrap = "import runpy, sys; sys.base_prefix=sys.prefix; sys.base_exec_prefix=sys.exec_prefix; sys.argv=['pip'] + sys.argv[1:]; runpy.run_module('pip', run_name='__main__')"
# This Python runtime can report a different base_prefix without having a
# pyvenv.cfg. Normalize only pip's process so it installs into this interpreter
# without emitting pip's misleading broken-virtualenv warning.
python -c $pipBootstrap install --upgrade pip --quiet
if ($LASTEXITCODE -ne 0) {
Write-Host " ERROR: pip upgrade failed." -ForegroundColor Red
exit 1
}
python -c $pipBootstrap install -e . --quiet
if ($LASTEXITCODE -ne 0) {
Write-Host " ERROR: Package installation failed." -ForegroundColor Red
exit 1
}
Write-Host " Package installed successfully in editable mode." -ForegroundColor Green
# 3b. Make installed CLI commands available permanently on Windows.
# Resolve the actual Scripts directory used by this Python interpreter so this
# works for both virtual environments and global Python installations.
Write-Host " Configuring command-line PATH..." -ForegroundColor Yellow
$scriptsDir = (python -c "import sysconfig; print(sysconfig.get_path('scripts'))").Trim()
if ([string]::IsNullOrWhiteSpace($scriptsDir)) {
Write-Host " WARNING: Could not determine Python Scripts directory." -ForegroundColor Yellow
} else {
$scriptsDir = [System.IO.Path]::GetFullPath($scriptsDir)
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$pathEntries = @()
if (-not [string]::IsNullOrWhiteSpace($userPath)) {
$pathEntries = $userPath -split ';' | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
}
$alreadyConfigured = $pathEntries | Where-Object {
[string]::Equals($_.TrimEnd('\'), $scriptsDir.TrimEnd('\'), [StringComparison]::OrdinalIgnoreCase)
}
if (-not $alreadyConfigured) {
$newUserPath = (($pathEntries + $scriptsDir) -join ';')
[Environment]::SetEnvironmentVariable("Path", $newUserPath, "User")
Write-Host " Added '$scriptsDir' to your permanent User PATH." -ForegroundColor Green
} else {
Write-Host " Python Scripts directory is already in your User PATH." -ForegroundColor Green
}
# Also update this installer process so the command can be used immediately.
$currentPathEntries = $env:Path -split ';'
$currentPathHasScripts = $currentPathEntries | Where-Object {
[string]::Equals($_.TrimEnd('\'), $scriptsDir.TrimEnd('\'), [StringComparison]::OrdinalIgnoreCase)
}
if (-not $currentPathHasScripts) {
$env:Path = "$env:Path;$scriptsDir"
}
# Notify Windows apps (including Explorer) that the persistent User PATH
# changed, so terminals opened afterward inherit the updated value.
if (-not ([System.Management.Automation.PSTypeName]'ArcRunner.EnvironmentBroadcast').Type) {
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
namespace ArcRunner {
public static class EnvironmentBroadcast {
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wParam,
string lParam, uint fuFlags, uint uTimeout, out UIntPtr lpdwResult);
}
}
"@
}
$broadcastResult = [UIntPtr]::Zero
[void][ArcRunner.EnvironmentBroadcast]::SendMessageTimeout(
[IntPtr]0xffff, 0x001A, [UIntPtr]::Zero, "Environment", 0x0002, 5000,
[ref]$broadcastResult
)
}
# 4. Hardware Self-Test
Write-Host "[4/4] Executing hardware discovery self-test..." -ForegroundColor Yellow
Write-Host ""
python -m arc_runner.cli.main devices
if ($LASTEXITCODE -eq 0) {
Write-Host " Verifying installed CLI command..." -ForegroundColor Yellow
arc-runner --version
if ($LASTEXITCODE -ne 0) {
Write-Host " ERROR: arc-runner CLI verification failed." -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "=================================================================" -ForegroundColor Green
Write-Host " Setup Complete! Intel Arc Models Runner is ready for local AI. " -ForegroundColor White
Write-Host " Run 'python -m arc_runner.cli.main devices' anytime to test. " -ForegroundColor Cyan
Write-Host "=================================================================" -ForegroundColor Green
Write-Host ""
} else {
Write-Host " Warning: Hardware probe returned an exit code of $LASTEXITCODE." -ForegroundColor Yellow
}