From c378cc40a23e7f6ac3ca23c6840ff638b16e78e9 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Wed, 11 Sep 2024 08:41:54 -0400 Subject: [PATCH] GP-4816: Not trying to create python virtual environment during prepdev is python is not installed --- Ghidra/Features/PyGhidra/build.gradle | 5 ++++- build.gradle | 7 ++++--- gradle/root/venv.gradle | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Ghidra/Features/PyGhidra/build.gradle b/Ghidra/Features/PyGhidra/build.gradle index 7eac96cb73..f701a80891 100644 --- a/Ghidra/Features/PyGhidra/build.gradle +++ b/Ghidra/Features/PyGhidra/build.gradle @@ -65,7 +65,10 @@ task installEditablePyGhidra(type: Exec) { commandLine "$PYTHON3_VENV", "-m", "pip", "install", "-e", "src/main/py" } -rootProject.prepDev.dependsOn installEditablePyGhidra + +if (findPython3(false)) { + rootProject.prepDev.dependsOn installEditablePyGhidra +} // Add pyghidra_launcher.py to the release rootProject.assembleDistribution { diff --git a/build.gradle b/build.gradle index c0abec5b7d..754a98c949 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,7 @@ if ("32".equals(System.getProperty("sun.arch.data.model"))) { * Identify supported Python command ***************************************************************************************/ project.ext.SUPPORTED_PY_VERSIONS = ['3.12', '3.11', '3.10', '3.9'] -project.ext.PYTHON3 = findPython3() +project.ext.PYTHON3 = findPython3(true) project.ext.PYTHON_DEPS = new HashSet() /********************************************************************************* @@ -198,7 +198,7 @@ def checkPip(String pyCmd) { } } -def findPython3() { +def findPython3(boolean useDefault) { for (pyCmd in ['py', 'python3', 'python']) { def pyVer = checkPythonVersion(pyCmd) if (pyVer in SUPPORTED_PY_VERSIONS) { @@ -219,7 +219,8 @@ def findPython3() { // Force use of non-existent python3.9 instead of unsupported python version // which should fail if a python build is performed. println("Warning: Python3 command not found (required for build)") - return 'python3.9' + + return useDefault ? 'python3.9' : null } /****************************************************************************************** diff --git a/gradle/root/venv.gradle b/gradle/root/venv.gradle index 96fd614925..29a292847d 100644 --- a/gradle/root/venv.gradle +++ b/gradle/root/venv.gradle @@ -28,4 +28,6 @@ task createPythonVirtualEnvironment(type: Exec) { commandLine rootProject.PYTHON3, "-m", "venv", venvDir, "--copies" } -rootProject.prepDev.dependsOn createPythonVirtualEnvironment +if (findPython3(false)) { + rootProject.prepDev.dependsOn createPythonVirtualEnvironment +}