windows10-base / scripts /setup.win10.ps1
NullVoider's picture
Upload folder using huggingface_hub
cf68e88 verified
raw
history blame
3.65 kB
# =============================================================================
# setup-win10.ps1
# One-command clone + automatic download of win10.qcow2 into win10-image/
# =============================================================================
$ErrorActionPreference = 'Stop' # Exit immediately if any command fails
$GithubRepo = "https://github.com/nullvoider07/windows10-base"
$RepoName = Split-Path $GithubRepo -Leaf
Write-Host "πŸš€ Cloning GitHub repo: $GithubRepo"
# ----------------------------- Clone with GitHub CLI -----------------------
Write-Host "πŸ”§ Checking GitHub CLI..."
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
Write-Host " GitHub CLI not found. Installing via winget..."
# Install gh silently, accepting agreements automatically
winget install --id GitHub.cli --exact --accept-source-agreements --accept-package-agreements
# Refresh the PATH variables in the current session so 'gh' is recognized immediately
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
# Verify installation succeeded
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
throw "❌ Failed to install GitHub CLI automatically. Please install it manually from https://cli.github.com"
}
Write-Host " βœ… GitHub CLI installed successfully."
} else {
Write-Host " βœ… GitHub CLI already available."
}
gh repo clone $GithubRepo $RepoName -- --depth=1
# ----------------------------- Create folder -------------------------------
Write-Host "πŸ“ Creating folder: win10-image/"
$ImagePath = Join-Path $RepoName "win10-image"
New-Item -ItemType Directory -Force -Path $ImagePath | Out-Null
# ----------------------------- Ensure uv is available ---------------------
Write-Host "πŸ”§ Checking uv..."
if (Get-Command uv -ErrorAction SilentlyContinue) {
Write-Host " uv already available β€” skipping installation."
} else {
Write-Host " Installing uv package manager..."
Invoke-RestMethod -Uri https://astral.sh/uv/install.ps1 | Invoke-Expression
$env:Path += ";$HOME\.cargo\bin;$HOME\.local\bin"
}
# ----------------------------- Ephemeral venv for huggingface-cli ----------
Write-Host "πŸ”§ Creating ephemeral venv for huggingface-cli..."
$TempDir = [System.IO.Path]::GetTempPath()
$HfVenv = Join-Path $TempDir "hf-venv-$(New-Guid)"
# uv venv picks the correct current Python automatically
uv venv $HfVenv --quiet
# Install directly into the venv β€” no --system, no activation needed
uv pip install --python "$HfVenv\Scripts\python.exe" transformers --quiet
Write-Host " βœ… huggingface-hub installed in ephemeral venv."
# ----------------------------- Download QCOW2 ------------------------------
Write-Host "πŸ“₯ Downloading win10.qcow2 (large file) into $RepoName\win10-image\ ..."
Write-Host " (This may take a while β€” progress bar will show)"
# Call huggingface-cli directly by its venv path β€” no PATH lookup, no cache
& "$HfVenv\Scripts\hf.exe" download NullVoider/windows10-base win10.qcow2 --local-dir $ImagePath
# ----------------------------- Cleanup venv --------------------------------
Write-Host "🧹 Cleaning up ephemeral venv..."
Remove-Item -Recurse -Force $HfVenv
# ----------------------------- Final message -------------------------------
Write-Host ""
Write-Host "βœ… SUCCESS!" -ForegroundColor Green
Write-Host " Repository cloned β†’ $RepoName\"
Write-Host " QCOW2 image ready at: $RepoName\win10-image\win10.qcow2"
Write-Host ""
Write-Host " Next time just run: cd $RepoName ; git pull"