-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_local_build.ps1
More file actions
79 lines (71 loc) · 3.36 KB
/
test_local_build.ps1
File metadata and controls
79 lines (71 loc) · 3.36 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
# Test local build with VS 2026 (without cibuildwheel)
# Usage:
# .\test_local_build.ps1 # Incremental build (fast, skips reinstall)
# .\test_local_build.ps1 -Install # Build and install wheel
# .\test_local_build.ps1 -Clean # Clean build artifacts
# .\test_local_build.ps1 -CleanAll # Clean everything including cache
param(
[switch]$Install, # Install the wheel after building
[switch]$Clean, # Clean build artifacts (build, _skbuild, dist)
[switch]$CleanAll # Clean everything including cache
)
Write-Host "Testing local build with VS 2026..." -ForegroundColor Green
# Check conda environment
$condaPrefix = $env:CONDA_PREFIX
if (-not $condaPrefix) {
Write-Host "CONDA_PREFIX environment variable is not set. Please activate your conda environment." -ForegroundColor Red
exit 1
}
# Clean if requested
if ($CleanAll) {
Write-Host "Cleaning all build artifacts and cache..." -ForegroundColor Yellow
if (Test-Path "build") { Remove-Item -Recurse -Force "build" }
if (Test-Path "_skbuild") { Remove-Item -Recurse -Force "_skbuild" }
if (Test-Path "dist") { Remove-Item -Recurse -Force "dist" }
if (Test-Path "cache") { Remove-Item -Recurse -Force "cache" }
} elseif ($Clean) {
Write-Host "Cleaning build artifacts..." -ForegroundColor Yellow
if (Test-Path "build") { Remove-Item -Recurse -Force "build" }
if (Test-Path "_skbuild") { Remove-Item -Recurse -Force "_skbuild" }
if (Test-Path "dist") { Remove-Item -Recurse -Force "dist" }
} else {
Write-Host "Using incremental build (use -Clean or -CleanAll to rebuild)" -ForegroundColor Cyan
}
# Initialize VS 2026 environment
Write-Host "Initializing VS 2026 environment..." -ForegroundColor Yellow
$vsPath = "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Auxiliary\Build\vcvarsall.bat"
if (Test-Path $vsPath) {
cmd /c "`"$vsPath`" x64 && set" | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') {
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2])
}
}
Write-Host "VS 2026 environment initialized" -ForegroundColor Green
} else {
Write-Host "Warning: VS 2026 not found at expected location" -ForegroundColor Yellow
}
# Build wheel using pip (--no-build-isolation to skip reinstalling build deps)
Write-Host "`nBuilding wheel..." -ForegroundColor Green
python -m pip wheel . --no-deps --no-build-isolation -w dist -v
if ($LASTEXITCODE -eq 0) {
Write-Host "`nBuild successful!" -ForegroundColor Green
Write-Host "`nWheels built:" -ForegroundColor Cyan
Get-ChildItem dist\*.whl | ForEach-Object {
Write-Host " $($_.Name)" -ForegroundColor Cyan
}
if ($Install) {
# Install wheel (skip dependencies to save time)
Write-Host "`nInstalling wheel..." -ForegroundColor Green
$wheel = Get-ChildItem dist\*.whl | Sort-Object LastWriteTime -Descending | Select-Object -First 1
pip install --force-reinstall --no-deps $wheel.FullName
python -c "import fastmm; print('fastmm version:', fastmm.__version__)"
# Run pytest after install
Write-Host "`nRunning pytest on installed wheel..." -ForegroundColor Green
pytest test_fastmm.py -v
} else {
Write-Host "`nSkipping installation (use -Install flag to install)" -ForegroundColor Cyan
}
} else {
Write-Host "`nBuild failed!" -ForegroundColor Red
exit 1
}