-
Notifications
You must be signed in to change notification settings - Fork 93
Update python3 to 3.13 #1547
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
base: main
Are you sure you want to change the base?
Update python3 to 3.13 #1547
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,21 +21,47 @@ try { | |||||
| VM-Pip-Install $installValue | ||||||
|
|
||||||
| if ($LastExitCode -eq 0) { | ||||||
| Write-Host "`t[+] Installed Python 3.10 module: $($module.name)" -ForegroundColor Green | ||||||
| Write-Host "`t[+] Installed Python 3.13 module: $($module.name)" -ForegroundColor Green | ||||||
| } else { | ||||||
| Write-Host "`t[!] Failed to install Python 3.10 module: $($module.name)" -ForegroundColor Red | ||||||
| Write-Host "`t[!] Failed to install Python 3.13 module: $($module.name)" -ForegroundColor Red | ||||||
| $failures += $module.Name | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if ($failures.Count -gt 0) { | ||||||
| foreach ($module in $failures) { | ||||||
| VM-Write-Log "ERROR" "Failed to install Python 3.10 module: $module" | ||||||
| VM-Write-Log "ERROR" "Failed to install Python 3.13 module: $module" | ||||||
| } | ||||||
| $outputFile = $outputFile.replace('lib\', 'lib-bad\') | ||||||
| VM-Write-Log "ERROR" "Check $outputFile for more information" | ||||||
| exit 1 | ||||||
| } | ||||||
|
|
||||||
| # Add Monkey Patch to `pyreadline3` for Python 3.13 compatibility | ||||||
| $sitePackages = python -c "import site; print(site.getsitepackages()[1])" | ||||||
| $potentialPath = Join-Path $sitePackages "readline.py" | ||||||
| if (Test-Path $potentialPath) { | ||||||
| $targetFile = $potentialPath | ||||||
| } else { | ||||||
| # Fallback, just in case. | ||||||
| try { | ||||||
| $targetFile = & $(Get-Command python).Source -c "import sys; sys.path.append(r'C:\Python313\Lib\site-packages'); import readline; print(readline.__file__)" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify python version to be 3.13 for automatically importing the right readline module without hardcoding its directory.
Suggested change
|
||||||
| } catch { | ||||||
| $targetFile = $null | ||||||
| } | ||||||
| } | ||||||
| if ($targetFile -and (Test-Path $targetFile)) { | ||||||
| $content = Get-Content $targetFile -Raw | ||||||
| if ($content -match "backend = 'pyreadline'") { | ||||||
| Write-Host "Already patched!" -ForegroundColor Yellow | ||||||
| } else { | ||||||
| Add-Content -Path $targetFile -Value "`n# Patch for Python 3.13`nbackend = 'pyreadline'" | ||||||
| Write-Host "Patch applied to: $targetFile" -ForegroundColor Green | ||||||
| } | ||||||
| } else { | ||||||
| Write-Host "Could not locate readline file." -ForegroundColor Red | ||||||
| } | ||||||
|
|
||||||
| # Avoid WARNINGs to fail the package install | ||||||
| exit 0 | ||||||
| } catch { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> | ||
| <metadata> | ||
| <id>stringsifter.vm</id> | ||
| <version>3.0.0.20230711</version> | ||
| <authors>Philip Tully (FDS), Matthew Haigh (FLARE), Jay Gibble (FLARE), and Michael Sikorski (FLARE)</authors> | ||
| <description>StringSifter is a machine learning tool that automatically ranks strings based on their relevance for malware analysis.</description> | ||
| <dependencies> | ||
| <dependency id="common.vm" version="0.0.0.20250206" /> | ||
| <!-- stringsifter.vm only verified to work up to python 3.11 --> | ||
| <dependency id="python311" /> | ||
| </dependencies> | ||
| <tags>File Information</tags> | ||
| <projectUrl>https://github.com/mandiant/stringsifter</projectUrl> | ||
| </metadata> | ||
| </package> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| $ErrorActionPreference = 'Stop' | ||
| Import-Module vm.common -Force -DisableNameChecking | ||
|
|
||
| $toolName = 'stringsifter' | ||
| $category = VM-Get-Category($MyInvocation.MyCommand.Definition) | ||
|
|
||
| # Create output file to log python module installation details | ||
| $outputFile = VM-New-Install-Log ${Env:VM_COMMON_DIR} | ||
| Invoke-Expression "py -3.11 -W ignore -m pip install $toolName --disable-pip-version-check 2>&1 >> $outputFile" | ||
|
|
||
| $cmdPath = (Get-Command cmd.exe).Source | ||
| VM-Install-Shortcut -toolName $toolName -category $category -executablePath "flarestrings" -consoleApp $true -iconLocation $cmdPath |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| $ErrorActionPreference = 'Continue' | ||
| Import-Module vm.common -Force -DisableNameChecking | ||
|
|
||
| $toolName = 'stringsifter' | ||
| $category = VM-Get-Category($MyInvocation.MyCommand.Definition) | ||
|
|
||
| Invoke-Expression "py -3.11 -m pip uninstall $toolName -y --disable-pip-version-check 2>&1" | ||
| VM-Remove-Tool-Shortcut $toolName $category |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| $ErrorActionPreference = 'Stop' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Import-Module vm.common -Force -DisableNameChecking | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| $toolName = 'unpy2exe' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| $category = VM-Get-Category($MyInvocation.MyCommand.Definition) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create output file to log python module installation details | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| $outputFile = VM-New-Install-Log ${Env:VM_COMMON_DIR} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Invoke-Expression "py -3.11 -W ignore -m pip install $toolName --disable-pip-version-check 2>&1 >> $outputFile" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| $pyPath = (Get-Command py).Source | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| VM-Install-Shortcut -toolName $toolName -category $category -executablePath $pyPath -consoleApp $true -arguments "-3.11 -m unpy2exe" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+12
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| $ErrorActionPreference = 'Continue' | ||
| Import-Module vm.common -Force -DisableNameChecking | ||
|
|
||
| $toolName = 'unpy2exe' | ||
| $category = VM-Get-Category($MyInvocation.MyCommand.Definition) | ||
|
|
||
| Invoke-Expression "py -3.11 -m pip uninstall $toolName -y --disable-pip-version-check 2>&1" | ||
| VM-Remove-Tool-Shortcut $toolName $category |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> | ||
| <metadata> | ||
| <id>unpy2exe.vm</id> | ||
| <version>0.0.0.20251215</version> | ||
| <authors>Matias Bordese</authors> | ||
| <description>unpy2exe extracts .pyc files from executables created with py2exe.</description> | ||
| <dependencies> | ||
| <dependency id="common.vm" version="0.0.0.20250206" /> | ||
| <!-- unpy2exe.vm only verified to work up to python 3.11 --> | ||
| <dependency id="python311" /> | ||
| </dependencies> | ||
| <tags>Python</tags> | ||
| <projectUrl>https://github.com/matiasb/unpy2exe</projectUrl> | ||
| </metadata> | ||
| </package> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify the python version.