From a807d4f6995e59596c3836418518a8e928cb40f4 Mon Sep 17 00:00:00 2001 From: Coding for fun Date: Wed, 20 Dec 2023 15:08:05 +0100 Subject: [PATCH] Switch to poetry for python package management for higher speed. --- setup/install_python_tools.ps1 | 68 +++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/setup/install_python_tools.ps1 b/setup/install_python_tools.ps1 index 64f7bcc..3ac4991 100644 --- a/setup/install_python_tools.ps1 +++ b/setup/install_python_tools.ps1 @@ -19,12 +19,20 @@ Get-Job | Receive-Job >> "C:\log\python.txt" 2>&1 Write-DateLog "Install packages in venv default in sandbox." >> "C:\log\python.txt" Start-Process -Wait -FilePath "$PYTHON_BIN" -ArgumentList "-m venv C:\venv\default" C:\venv\default\Scripts\Activate.ps1 >> "C:\log\python.txt" +Set-Location "C:\venv\default\" python -m pip install -U pip >> "C:\log\python.txt" -python -m pip install -U setuptools wheel >> "C:\log\python.txt" +python -m pip install -U poetry >> "C:\log\python.txt" # TODO: Get latest version of package python -m pip install https://github.com/msuhanov/dfir_ntfs/archive/1.1.18.tar.gz >> "C:\log\python.txt" -python -m pip install --prefer-binary ` +poetry init ` + --name default ` + --description "Default Python venv for dfirws." ` + --author "dfirws" ` + --license "MIT" ` + --no-interaction + +poetry add ` aiohttp[speedups] ` aiosignal>=1.2.0 ` annotated-types>=0.5.0 ` @@ -186,12 +194,12 @@ python -m pip install --prefer-binary ` typing-extensions>=4.7.1 ` tzdata>=2023.1 ` tzlocal>=5.1 ` - uncompyle6 ` unicorn ` unpy2exe ` urllib3>=2.1.0 ` visidata>=2.11 ` werkzeug>=3.0.1 ` + wrapt>=1.15.0 ` xlrd>=2.0.0 ` XLMMacroDeobfuscator>=0.2.6 ` XlsxWriter>=3.1.8 ` @@ -231,7 +239,7 @@ Copy-Item "$SETUP_PATH\vs_BuildTools.exe" "$TEMP\vs_BuildTools.exe" Set-Location $Temp Start-Process -Wait ".\vs_BuildTools.exe" -ArgumentList "-p --norestart --force --installWhileDownloading --add Microsoft.VisualStudio.Product.BuildTools --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.Windows11SDK.22000 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --installPath C:\BuildTools" Get-Job | Receive-Job >> "C:\log\python.txt" 2>&1 -& 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat' >> "C:\log\python.txt" 2>&1 +& 'C:\BuildTools\Common7\Tools\VsDevCmd.bat' >> "C:\log\python.txt" 2>&1 # Install Java. Write-DateLog "Start installation of Corretto Java." >> "C:\log\python.txt" 2>&1 @@ -244,15 +252,27 @@ $env:JAVA_HOME="C:\Program Files\Amazon Corretto\"+(Get-ChildItem 'C:\Program Fi Write-DateLog "Install packages in venv jep in sandbox (needs older packages)." >> "C:\log\python.txt" Start-Process -Wait -FilePath "$PYTHON_BIN" -ArgumentList "-m venv --system-site-packages C:\venv\jep" C:\venv\jep\Scripts\Activate.ps1 >> "C:\log\python.txt" +Set-Location "C:\venv\jep" python -m pip install -U pip >> "C:\log\python.txt" -python -m pip install -U setuptools wheel 2>&1 >> "C:\log\python.txt" -python -m pip install NumPy flare-capa 2>&1 >> "C:\log\python.txt" +python -m pip install -U poetry 2>&1 >> "C:\log\python.txt" + +poetry init ` + --name jepvenv ` + --description "Python venv for jep." ` + --author "dfirws" ` + --license "MIT" ` + --no-interaction + +poetry add ` + NumPy ` + flare-capa ` + jep 2>&1 >> "C:\log\python.txt" # Build Ghidrathon for Gidhra Write-DateLog "Build Ghidrathon for Ghidra." Copy-Item -Recurse "C:\Tools\ghidrathon" "$TEMP" Set-Location "$TEMP\ghidrathon" -& "$TOOLS\gradle\bin\gradle.bat" -PGHIDRA_INSTALL_DIR="C:\Tools\ghidra" -PPYTHON_BIN="C:\venv\jep\Scripts\python.exe" >> "C:\log\python.txt" 2>&1 +& "$TOOLS\gradle\bin\gradle.bat" -PGHIDRA_INSTALL_DIR="C:\Tools\ghidra" -PPYTHON_BIN="C:\venv\jep\Scripts\python.exe" >> "C:\log\python.txt" Copy-Item $TEMP\ghidrathon\dist\ghidra* "C:\Tools\ghidra_extensions\ghidrathon.zip" >> "C:\log\python.txt" 2>&1 deactivate Write-DateLog "Python venv jep done." >> "C:\log\python.txt" @@ -261,9 +281,18 @@ Write-DateLog "Python venv jep done." >> "C:\log\python.txt" Write-DateLog "Install packages in venv dfir-unfurl in sandbox (needs older packages)." >> "C:\log\python.txt" Start-Process -Wait -FilePath "$PYTHON_BIN" -ArgumentList "-m venv C:\venv\dfir-unfurl" C:\venv\dfir-unfurl\Scripts\Activate.ps1 >> "C:\log\python.txt" +Set-Location "C:\venv\dfir-unfurl" python -m pip install -U pip >> "C:\log\python.txt" -python -m pip install -U setuptools wheel >> "C:\log\python.txt" -python -m pip install ` +python -m pip install -U poetry >> "C:\log\python.txt" + +poetry init ` + --name dfir-unfurlvenv ` + --description "Python venv for dfir-unfurl." ` + --author "dfirws" ` + --license "MIT" ` + --no-interaction + +poetry add ` dfir-unfurl ` hexdump ` tomlkit 2>&1 >> "C:\log\python.txt" @@ -289,9 +318,18 @@ Write-DateLog "Python venv dfir-unfurl cache done." >> "C:\log\python.txt" Write-DateLog "Install packages in venv pySigma in sandbox (needs older packages that conflicts with oletools)." >> "C:\log\python.txt" Start-Process -Wait -FilePath "$PYTHON_BIN" -ArgumentList "-m venv C:\venv\pySigma" C:\venv\pySigma\Scripts\Activate.ps1 >> "C:\log\python.txt" +Set-Location "C:\venv\pySigma" python -m pip install -U pip >> "C:\log\python.txt" -python -m pip install -U setuptools wheel >> "C:\log\python.txt" -python -m pip install ` +python -m pip install -U poetry >> "C:\log\python.txt" + +poetry init ` + --name pySigmavenv ` + --description "Python venv for pySigma." ` + --author "dfirws" ` + --license "MIT" ` + --no-interaction + +poetry add ` pySigma>=0.9.6 ` wheel>=0.41.3 2>&1 >> "C:\log\python.txt" deactivate @@ -372,7 +410,8 @@ Start-Process -Wait -FilePath "$PYTHON_BIN" -ArgumentList "-m venv C:\venv\chepy C:\venv\chepy\Scripts\Activate.ps1 >> "C:\log\python.txt" python -m pip install -U pip >> "C:\log\python.txt" python -m pip install -U setuptools wheel 2>&1 >> "C:\log\python.txt" -python -m pip install chepy[extras] 2>&1 >> "C:\log\python.txt" +python -m pip install ` + chepy[extras] 2>&1 >> "C:\log\python.txt" deactivate Set-Content "C:\venv\chepy\Scripts\python.exe C:\venv\chepy\Scripts\chepy.py `$args" -Encoding Ascii -Path C:\venv\default\Scripts\chepy.ps1 Write-DateLog "Python venv chepy done." >> "C:\log\python.txt" @@ -383,7 +422,10 @@ Start-Process -Wait -FilePath "$PYTHON_BIN" -ArgumentList "-m venv C:\venv\disse C:\venv\dissect\Scripts\Activate.ps1 >> "C:\log\python.txt" python -m pip install -U pip >> "C:\log\python.txt" python -m pip install -U setuptools wheel 2>&1 >> "C:\log\python.txt" -python -m pip install acquire dissect flow.record 2>&1 >> "C:\log\python.txt" +python -m pip install ` + acquire ` + dissect ` + flow.record 2>&1 >> "C:\log\python.txt" deactivate Set-Content "C:\venv\dissect\Scripts\python.exe C:\venv\dissect\Scripts\dissect.py `$args" -Encoding Ascii -Path C:\venv\default\Scripts\dissect.ps1 Write-DateLog "Python venv dissect done." >> "C:\log\python.txt"