-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsetup-dev.ps1
More file actions
209 lines (179 loc) · 5.85 KB
/
setup-dev.ps1
File metadata and controls
209 lines (179 loc) · 5.85 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/env pwsh
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#Requires -Version 7.0
<#
.SYNOPSIS
Development environment setup for azure-nvidia-robotics-reference-architecture.
.DESCRIPTION
Verifies required tools, installs uv, sets up Python virtual environment,
clones IsaacLab, and checks for hve-core.
.PARAMETER DisableVenv
Skip virtual environment creation; install packages directly.
.EXAMPLE
./setup-dev.ps1
.EXAMPLE
./setup-dev.ps1 -DisableVenv
#>
[CmdletBinding()]
param(
[switch]$DisableVenv
)
$ErrorActionPreference = 'Stop'
#region Helper Functions
function Write-Info {
param([string]$Message)
if ($env:NO_COLOR) {
Write-Host "[INFO] $Message"
}
else {
Write-Host "[INFO] $Message" -ForegroundColor Blue
}
}
function Write-Warn {
param([string]$Message)
if ($env:NO_COLOR) {
Write-Warning "[WARN] $Message"
}
else {
Write-Host "[WARN] $Message" -ForegroundColor Yellow
}
}
function Write-Section {
param([string]$Title)
Write-Host ''
Write-Host '============================'
Write-Host $Title
Write-Host '============================'
}
function Assert-Tools {
param([string[]]$Tools)
$missing = @()
foreach ($tool in $Tools) {
if (-not (Get-Command $tool -ErrorAction SilentlyContinue)) {
$missing += $tool
}
}
if ($missing.Count -gt 0) {
Write-Error "Missing required tools: $($missing -join ', ')"
}
}
#endregion
$ScriptDir = $PSScriptRoot
$VenvDir = Join-Path $ScriptDir '.venv'
# Devcontainer recommendation
Write-Host ''
Write-Host ([char]0x1F4A1 + ' RECOMMENDED: Use the Dev Container for the best experience.')
Write-Host ''
Write-Host 'The devcontainer includes all tools pre-configured:'
Write-Host ' - Azure CLI, Terraform, kubectl, helm, jq'
Write-Host ' - Python with all dependencies'
Write-Host ' - VS Code extensions for Terraform and Python'
Write-Host ''
Write-Host 'To use:'
Write-Host ' VS Code -> Reopen in Container (F1 -> Dev Containers: Reopen)'
Write-Host ' Codespaces -> Open in Codespace from GitHub'
Write-Host ''
Write-Host 'If this script fails, the devcontainer is your fallback.'
Write-Host ''
Write-Section 'Tool Verification'
Assert-Tools az, terraform, kubectl, helm, jq
Write-Info 'All required tools found'
Write-Section 'UV Package Manager Setup'
$UvVersion = '0.7.12'
if (-not (Get-Command uv -ErrorAction SilentlyContinue)) {
Write-Info "Installing uv package manager v$UvVersion..."
$uvInstaller = Join-Path ([System.IO.Path]::GetTempPath()) 'uv-install.ps1'
try {
Invoke-WebRequest -Uri "https://astral.sh/uv/$UvVersion/install.ps1" -OutFile $uvInstaller -UseBasicParsing
& $uvInstaller
}
finally {
Remove-Item $uvInstaller -Force -ErrorAction SilentlyContinue
}
if (-not $IsWindows) {
$env:PATH = "$HOME/.local/bin:$HOME/.cargo/bin:$env:PATH"
}
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to install uv v$UvVersion"
}
}
Write-Info "Using uv: $(uv --version)"
Write-Section 'Python Environment Setup'
$PythonVersion = Get-Content (Join-Path $ScriptDir '.python-version') -Raw
$PythonVersion = $PythonVersion.Trim()
Write-Info "Target Python version: $PythonVersion"
if ($DisableVenv) {
Write-Info 'Virtual environment disabled, installing packages directly...'
}
else {
if (-not (Test-Path $VenvDir)) {
Write-Info "Creating virtual environment at $VenvDir with Python $PythonVersion..."
uv venv $VenvDir --python $PythonVersion
if ($LASTEXITCODE -ne 0) {
Write-Error "uv venv failed (exit code $LASTEXITCODE)"
}
}
else {
Write-Info "Virtual environment already exists at $VenvDir"
}
}
Write-Info 'Syncing dependencies from pyproject.toml...'
uv sync
if ($LASTEXITCODE -ne 0) {
Write-Error "uv sync failed (exit code $LASTEXITCODE)"
}
Write-Info 'Locking dependencies...'
uv lock
if ($LASTEXITCODE -ne 0) {
Write-Error "uv lock failed (exit code $LASTEXITCODE)"
}
Write-Section 'IsaacLab Setup'
$IsaacLabDir = Join-Path $ScriptDir 'external' 'IsaacLab'
if (Test-Path $IsaacLabDir) {
Write-Info "IsaacLab already cloned at $IsaacLabDir"
Write-Info "To update, run: cd $IsaacLabDir && git pull"
}
else {
Write-Info 'Cloning IsaacLab for intellisense/Pylance support...'
New-Item -ItemType Directory -Path (Join-Path $ScriptDir 'external') -Force | Out-Null
git clone 'https://github.com/isaac-sim/IsaacLab.git' $IsaacLabDir
if ($LASTEXITCODE -ne 0) {
Write-Error "git clone failed (exit code $LASTEXITCODE)"
}
Write-Info 'IsaacLab cloned successfully'
}
Write-Section 'hve-core Check'
$HveCoreDir = Join-Path $ScriptDir '..' 'hve-core'
if (-not (Test-Path $HveCoreDir)) {
Write-Warn "hve-core not found at $HveCoreDir"
Write-Warn 'Install for Copilot workflows: https://github.com/microsoft/hve-core/blob/main/docs/getting-started/install.md'
Write-Warn 'Or install the VS Code Extension: ise-hve-essentials.hve-core'
}
else {
Write-Info "hve-core found at $HveCoreDir"
}
Write-Section 'Setup Complete'
Write-Host ''
Write-Host 'Development environment setup complete!'
Write-Host ''
if (-not $DisableVenv) {
Write-Warn 'Run this command to activate the virtual environment:'
Write-Host ''
if ($IsWindows) {
Write-Host ' .venv\Scripts\Activate.ps1'
}
else {
Write-Host ' source .venv/bin/activate'
}
Write-Host ''
}
Write-Host 'Next steps:'
Write-Host ' 1. Run: . deploy/000-prerequisites/az-sub-init.ps1'
Write-Host ' 2. Configure: deploy/001-iac/terraform.tfvars'
Write-Host ' 3. Deploy: cd deploy/001-iac && terraform init && terraform apply'
Write-Host ''
Write-Host 'Documentation:'
Write-Host ' - README.md - Quick start guide'
Write-Host ' - deploy/README.md - Deployment overview'
Write-Host ''