Skip to content

Commit

Permalink
Fix Windows Python package uninstallation (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmapetr authored Apr 29, 2020
1 parent 97a6630 commit 76790a5
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions installers/win-setup-template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,30 @@ if (-Not (Test-Path $PythonToolcachePath))
}

Write-Host "Check if current Python version is installed..."
$InstalledVersion = Get-ChildItem -Path $PythonToolcachePath -Filter "$MajorVersion.$MinorVersion.*"
$InstalledVersions = Get-Item "$PythonToolcachePath\$MajorVersion.$MinorVersion.*\$Architecture"

Write-Host "Remove registry entries for Python ${MajorVersion}.${MinorVersion}(${Architecture})..."
Remove-RegistryEntries -Architecture $Architecture -MajorVersion $MajorVersion -MinorVersion $MinorVersion
if ($null -ne $InstalledVersions)
{
Write-Host "Python$MajorVersion.$MinorVersion ($Architecture) was found in $PythonToolcachePath..."

if (($null -ne $InstalledVersion) -and (Test-Path -Path $InstalledVersion.FullName)) {
Write-Host "Python$MajorVersion.$MinorVersion was found in $PythonToolcachePath"
Write-Host "Deleting $($InstalledVersion.FullName)..."
Remove-Item -Path $InstalledVersion.FullName -Recurse -Force
} else {
foreach ($InstalledVersion in $InstalledVersions)
{
if (Test-Path -Path $InstalledVersion)
{
Write-Host "Deleting $InstalledVersion..."
Remove-Item -Path $InstalledVersion -Recurse -Force
Remove-Item -Path "$($InstalledVersion.Parent.FullName)/${Architecture}.complete" -Force -Verbose
}
}
}
else
{
Write-Host "No Python$MajorVersion.$MinorVersion.* found"
}

Write-Host "Remove registry entries for Python ${MajorVersion}.${MinorVersion}(${Architecture})..."
Remove-RegistryEntries -Architecture $Architecture -MajorVersion $MajorVersion -MinorVersion $MinorVersion

Write-Host "Create Python $Version folder in $PythonToolcachePath"
New-Item -ItemType Directory -Path $PythonArchPath -Force | Out-Null

Expand Down

0 comments on commit 76790a5

Please sign in to comment.