param( [string]$PythonExe = "C:\Users\Maddo\.pyenv\pyenv-win\versions\3.11.6\python.exe", [string]$GhidraInstallDir = "I:\Apps\ghidra_12.0.4_PUBLIC", [string]$VenvPath = (Join-Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ".venv-pyghidra311") ) $ErrorActionPreference = "Stop" $resolvedPython = (Resolve-Path $PythonExe).Path $resolvedGhidra = (Resolve-Path $GhidraInstallDir).Path $pyghidraDist = Join-Path $resolvedGhidra "Ghidra\Features\PyGhidra\pypkg\dist" $ghidraStubsDist = Join-Path $resolvedGhidra "docs\ghidra_stubs" if (-not (Test-Path $pyghidraDist)) { throw "Missing PyGhidra wheel directory: $pyghidraDist" } if (-not (Test-Path $ghidraStubsDist)) { throw "Missing Ghidra stubs wheel directory: $ghidraStubsDist" } & $resolvedPython -m venv $VenvPath $venvPython = Join-Path $VenvPath "Scripts\python.exe" if (-not (Test-Path $venvPython)) { throw "Virtual environment python not found at $venvPython" } & $venvPython -m pip install --upgrade --force-reinstall --no-index --find-links $pyghidraDist --find-links $ghidraStubsDist pyghidra==3.0.2 ghidra-stubs==12.0.4 $versionScript = @' from importlib.metadata import version print(f"pyghidra={version('pyghidra')}") print(f"ghidra-stubs={version('ghidra-stubs')}") '@ & $venvPython -c $versionScript