Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win-64 test #111

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
070cc80
initial commit
eightysteele Aug 14, 2024
fca5a26
do not checkout branch
eightysteele Aug 14, 2024
12e529a
install path tweak
eightysteele Aug 14, 2024
7db59b5
ssh update
eightysteele Aug 14, 2024
9e8c2c5
adc
eightysteele Aug 14, 2024
1bbe3ff
adc
eightysteele Aug 14, 2024
89767b0
installer
eightysteele Aug 14, 2024
d9b4915
rerun + scp
eightysteele Aug 15, 2024
d9ede1c
rerun + update
eightysteele Aug 15, 2024
fbe561d
adc
eightysteele Aug 15, 2024
285b6a6
installer
eightysteele Aug 15, 2024
f5a8929
installer return
eightysteele Aug 15, 2024
9ed4178
installer return 1
eightysteele Aug 15, 2024
8c12a2e
return
eightysteele Aug 15, 2024
26d4055
gcp adc
eightysteele Aug 15, 2024
a4b4635
gcp log
eightysteele Aug 15, 2024
36e6464
gcp user
eightysteele Aug 15, 2024
0de6c9b
install upgrade
eightysteele Aug 15, 2024
54b5834
install upgrade
eightysteele Aug 15, 2024
ee034ed
nits
eightysteele Aug 15, 2024
8a8b0c3
update
eightysteele Aug 15, 2024
b0f6e78
install
eightysteele Aug 15, 2024
b375f2e
path
eightysteele Aug 15, 2024
e5073c6
refactor
eightysteele Aug 16, 2024
ad829e8
auth flow
eightysteele Aug 16, 2024
9b9ec01
auth flow gh
eightysteele Aug 16, 2024
641b85d
nits
eightysteele Aug 16, 2024
dc2fd12
nits
eightysteele Aug 16, 2024
5dd6422
ux
eightysteele Aug 16, 2024
cd43fac
ux2
eightysteele Aug 16, 2024
4fcbfe5
ux4
eightysteele Aug 16, 2024
874e8f0
ux5
eightysteele Aug 16, 2024
bc7ab95
ux8
eightysteele Aug 16, 2024
f504e92
ux0
eightysteele Aug 16, 2024
9ea1f3e
ux22
eightysteele Aug 16, 2024
c39740f
task fix
eightysteele Aug 16, 2024
eca0035
task fix
eightysteele Aug 16, 2024
fe294c3
env up
eightysteele Aug 19, 2024
03fd5f5
env test
eightysteele Aug 19, 2024
93c4d5b
env test
eightysteele Aug 19, 2024
74124ee
env test win
eightysteele Aug 19, 2024
4e6674a
env test win
eightysteele Aug 19, 2024
10d4e20
env test win
eightysteele Aug 19, 2024
41764b1
env test term
eightysteele Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ repos:
hooks:
- id: pixi-update-default
name: pixi update (solving default)
entry: bash -c 'cd $(git rev-parse --show-toplevel) && pixi update -e default && git add pixi.lock'
entry: bash -c 'cd $(git rev-parse --show-toplevel) && pixi install --locked -e default && git add pixi.lock'
language: system
files: ^pyproject\.toml$
types: [text]

- id: pixi-update-cpu
name: pixi update (solving cpu)
entry: bash -c 'cd $(git rev-parse --show-toplevel) && pixi update -e cpu && git add pixi.lock'
entry: bash -c 'cd $(git rev-parse --show-toplevel) && pixi install --locked -e cpu && git add pixi.lock'
language: system
files: ^pyproject\.toml$
types: [text]

- id: pixi-update-gpu
name: pixi update (solving gpu)
entry: bash -c 'cd $(git rev-parse --show-toplevel) && pixi update -e gpu && git add pixi.lock'
entry: bash -c 'cd $(git rev-parse --show-toplevel) && pixi install --locked -e gpu && git add pixi.lock'
language: system
files: ^pyproject\.toml$
types: [text]
Expand Down
239 changes: 239 additions & 0 deletions install/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
# Installs b3d on Windows

$PixiHome = "$Env:USERPROFILE\.pixi"
$PixiBinDir = Join-Path $PixiHome 'bin'
$PipxHome = "$Env:USERPROFILE\.local"
$PipxBinDir = Join-Path $PipxHome 'bin'

$script:addedPaths = @()

function Update-PathPermanently {
param (
[string]$NewPath
)
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($currentPath -notlike "*$NewPath*") {
$newUserPath = "$currentPath;$NewPath"
[Environment]::SetEnvironmentVariable("PATH", $newUserPath, "User")
$Env:PATH = "$Env:PATH;$NewPath"

# Add to our tracking array
$script:addedPaths += $NewPath

Write-Output "Added to PATH: $NewPath"
} else {
Write-Output "PATH already contains: $NewPath"
}
}

function Update-PowerShellProfile {
param(
[string[]]$Paths
)

$pathsString = ($Paths | ForEach-Object { " `"$_`"" }) -join ",`n"

$newContent = @"
# Set USER environment variable
`$env:USER = `$env:USERNAME
# Also set it as a regular variable for easy access
`$global:USER = `$env:USERNAME

# Ensure critical directories are in PATH
`$criticalPaths = @(
$pathsString
)

foreach (`$path in `$criticalPaths) {
if (`$env:PATH -notlike "*`$path*") {
`$env:PATH += ";`$path"
}
}

# Set up Pixi completion
(& pixi completion --shell powershell) | Out-String | Invoke-Expression
"@

if (Test-Path $PROFILE) {
$currentContent = Get-Content $PROFILE -Raw
if ($currentContent -notmatch [regex]::Escape($newContent)) {
Set-Content -Path $PROFILE -Value $newContent
Write-Host "Profile updated with USER environment variable, PATH checks, and Pixi completion."
} else {
Write-Host "Profile already contains all required content."
}
} else {
Set-Content -Path $PROFILE -Value $newContent
Write-Host "Profile created with USER environment variable, PATH checks, and Pixi completion."
}
}

# Install Pixi
if (-not (Test-Path $PixiBinDir)) {
Write-Output "Installing Pixi..."
Invoke-Expression (Invoke-WebRequest -useb https://pixi.sh/install.ps1)
}

# Update PATH for Pixi
Update-PathPermanently $PixiBinDir

# Check if PowerShell profile exists, create if it doesn't
if (-not (Test-Path -Path $PROFILE)) {
Write-Output "PowerShell profile does not exist. Creating it..."
New-Item -ItemType File -Path $PROFILE -Force
}

# Add Pixi autocomplete to user profile
$AutoCompleteCommand = '(& pixi completion --shell powershell) | Out-String | Invoke-Expression'
if (-not (Select-String -Path $PROFILE -Pattern "pixi completion" -Quiet)) {
Add-Content -Path $PROFILE -Value $AutoCompleteCommand
# Load autocomplete in current session
Invoke-Expression $AutoCompleteCommand
}

# Refresh PATH to include Pixi
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")

# Install Pipx using Pixi
Write-Output "Installing Pipx..."
& pixi global install pipx

# Update PATH for Pipx
Update-PathPermanently $PipxBinDir

# Refresh PATH to include Pipx
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")

# Install keyring using Pipx
Write-Output "Installing keyring..."
& pipx install keyring --force
& pipx inject keyring keyrings.google-artifactregistry-auth --index-url https://pypi.org/simple --force

# Install other tools using Pixi
Write-Output "Installing Python, Git, and GitHub CLI..."
& pixi global install python git gh

# Check if a local browser is available
function Test-BrowserAvailable {
try {
$key = [Microsoft.Win32.Registry]::ClassesRoot.OpenSubKey("http\shell\open\command", $false)
$default = $key.GetValue("")
return $null -ne $default
}
catch {
return $false
}
}

# Check if we're in a remote session
function Test-RemoteSession {
return ((Get-Process -Name "mstsc" -ErrorAction SilentlyContinue) -or
(Get-ChildItem -Path Env:\ | Where-Object { $_.Name -like "*SESSIONNAME*" -and $_.Value -like "*RDP*" }) -or
($env:TERM_PROGRAM -eq "vscode") -or
[bool](Get-CimInstance -ClassName Win32_SystemAccount -Filter "Name = 'NETWORK SERVICE'" -ErrorAction SilentlyContinue))
}

# Set up GitHub CLI
if (-not (& gh auth status 2>$null)) {
Write-Output "Authenticating with GitHub..."

$browserAvailable = Test-BrowserAvailable
$isRemoteSession = Test-RemoteSession

if ($browserAvailable -and -not $isRemoteSession) {
# Local session with browser available
& gh auth login --web
} else {
# Remote session or no browser available
Write-Output "It seems you're in a remote session or no browser is available."
Write-Output "You can authenticate using a device code or a token."
$authMethod = Read-Host "Choose authentication method: [D]evice code or [T]oken"

if ($authMethod -eq 'D' -or $authMethod -eq 'd') {
& gh auth login
} elseif ($authMethod -eq 'T' -or $authMethod -eq 't') {
& gh auth login --with-token
Write-Output "Please paste your GitHub personal access token when prompted."
} else {
Write-Output "Invalid choice. Skipping GitHub authentication. Please run 'gh auth login' manually later."
}
}
}

# Set up Google Cloud SDK
$ADC_FILE_LOCAL = "$Env:USERPROFILE\AppData\Roaming\gcloud\application_default_credentials.json"
if (-not (Test-Path $ADC_FILE_LOCAL)) {
Write-Output "Authenticating with Google Cloud..."

$browserAvailable = Test-BrowserAvailable
$isRemoteSession = Test-RemoteSession

if ($browserAvailable -and -not $isRemoteSession) {
# Local session with browser available
& gcloud auth login --update-adc --force
} else {
# Remote session or no browser available
Write-Output "It seems you're in a remote session or no browser is available."
Write-Output "Please use this command to authenticate:"
Write-Output "gcloud auth login --no-browser --update-adc --force"

$proceed = Read-Host "Do you want to proceed with browser-less authentication now? (y/n)"
if ($proceed -eq 'y') {
& gcloud auth login --no-browser --update-adc --force
} else {
Write-Output "Skipping Google Cloud authentication. Please run the command manually later."
}
}
}

function Check-And-Handle-B3DDirectory {
$b3dPath = Join-Path $PWD "b3d"
if (Test-Path $b3dPath) {
Write-Host "A 'b3d' directory already exists in the current location."
$decision = Read-Host "Do you want to delete it? (y/n)"
if ($decision -eq 'y') {
try {
Remove-Item -Path $b3dPath -Recurse -Force
Write-Host "The 'b3d' directory has been deleted."
}
catch {
Write-Host "Error deleting the 'b3d' directory: $_"
Write-Host "Please delete the directory manually and run the script again."
exit
}
}
else {
Write-Host "The 'b3d' directory was not deleted. Exiting the script."
exit
}
}
else {
Write-Host "No existing 'b3d' directory found. Proceeding with the script."
}
}

Check-And-Handle-B3DDirectory

# Clone and checkout b3d repository
$B3D_BRANCH = "eightysteele/win-64-test"
if (-not (Test-Path "b3d")) {
Write-Output "Cloning b3d repository..."
& gh repo clone probcomp/b3d
Set-Location b3d
& git checkout $B3D_BRANCH
Set-Location ..
}

Write-Host "`nUpdating your PowerShell profile with PATH checks, USER environment variable, and Pixi completion..."

$allPaths = @(
"$env:USERPROFILE\.pixi\bin",
"$env:USERPROFILE\.local\bin"
)
$allPaths += $script:addedPaths | Select-Object -Unique

Update-PowerShellProfile -Paths $allPaths

Write-Output "Profile updates have been applied."
Write-Output "To ensure all changes take effect, please restart your PowerShell session or run:"
Write-Output ". `$PROFILE"
4 changes: 2 additions & 2 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ __wrap__() {
;;
esac

PATH=$BIN_DIR:$PIPX_BIN:$PATH
export PATH=$BIN_DIR:$PIPX_BIN:$PATH

printf "\n→ installing pipx into %s\n\n" "$BIN_DIR"
pixi global install pipx
Expand Down Expand Up @@ -326,7 +326,7 @@ __wrap__() {
cd "$B3D_ROOT" || exit 1

printf "\n→ checking out %s branch\n\n" "$B3D_BRANCH"
git checkout -b "$B3D_BRANCH" origin/"$B3D_BRANCH"
git checkout "$B3D_BRANCH" origin/"$B3D_BRANCH"

printf "\n→ installing pre-commit hooks %s\n\n" "$BIN_DIR"
pre-commit install
Expand Down
Loading
Loading