Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/libraries.python3.vm/libraries.python3.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>libraries.python3.vm</id>
<version>0.0.0.20251004</version>
<version>0.0.0.20251218</version>
<description>Python 3 libraries useful for common reverse engineering tasks.</description>
<authors>Several, check in pypi.org for every of the libraries</authors>
<dependencies>
Expand Down
44 changes: 35 additions & 9 deletions packages/libraries.python3.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,58 @@ try {
VM-Pip-Install "pip~=23.2.1"

$failures = @()
$pipArgs = @()
$modules = $modulesXml.modules.module

Write-Host "Attempting to install the following Python3 modules:"
foreach ($module in $modules) {
Write-Host "[+] Attempting to install Python3 module: $($module.name)"
Write-Host "[+] $($module.name)"
$installValue = $module.name
if ($module.url) {
$installValue = $module.url
}
$pipArgs += $installValue
}

Write-Host "Batch installing Python modules..."
$batchInstallString = $pipArgs -join " "
VM-Pip-Install $batchInstallString

VM-Pip-Install $installValue
foreach ($module in $modules) {
$pkgName = $module.name

if ($LastExitCode -eq 0) {
Write-Host "`t[+] Installed Python 3.10 module: $($module.name)" -ForegroundColor Green
# Clean up version pins (e.g., "pywin32==308" -> "pywin32") for install check
if ($pkgName -match "==") {
$pkgName = $pkgName -split "==" | Select-Object -First 1
}
if ($pkgName -match ">=") {
$pkgName = $pkgName -split ">=" | Select-Object -First 1
}

# 'pip show' returns exit code 0 if found, 1 if missing
$null = py -3.10 -m pip show $pkgName 2>&1

if ($LASTEXITCODE -ne 0) {
Write-Host "`t[!] Failed to install Python 3.10 module:$pkgName" -ForegroundColor Red
$failures += $pkgName
} else {
Write-Host "`t[!] Failed to install Python 3.10 module: $($module.name)" -ForegroundColor Red
$failures += $module.Name
Write-Host "`t[+] Installed Python 3.10 module: $pkgName" -ForegroundColor Green
}
}

if ($failures.Count -gt 0) {
foreach ($module in $failures) {
VM-Write-Log "ERROR" "Failed to install Python 3.10 module: $module"
}
$outputFile = $outputFile.replace('lib\', 'lib-bad\')
VM-Write-Log "ERROR" "Check $outputFile for more information"
exit 1
throw "Package installation failed. The following modules could not be verified: $($failures -join ', ')"
}

# Fix issue with chocolately printing incorrect install directory
$pythonPath = py -3.10 -c "import sys; print(sys.prefix)" 2>$null
if ($pythonPath) {
$env:ChocolateyPackageInstallLocation = $pythonPath
}

# Avoid WARNINGs to fail the package install
exit 0
} catch {
Expand Down