Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-4570 revisions to buildPyPackage task

ghidra1546f54f4187a
diff --git a/README.md b/README.md
index fc5a780617..e45f876324 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,7 @@ To create the latest development build for your platform from this source reposi
##### Install build tools:
* [JDK 17 64-bit][jdk17]
* [Gradle 7.3+][gradle]
-* [Python3][python3] and pip3
+* [Python3][python3] (version 3.7 to 3.12) with bundled pip
* make, gcc, and g++ (Linux/macOS-only)
* [Microsoft Visual Studio][vs] 2017+ or [Microsoft C++ Build Tools][vcbuildtools] with the
following components installed (Windows-only):
@@ -130,7 +130,6 @@ source project.
[jdk17]: https://adoptium.net/temurin/releases
[gradle]: https://gradle.org/releases/
[python3]: https://www.python.org/downloads/
-[python3-build]: https://pypi.org/project/build/
[vs]: https://visualstudio.microsoft.com/vs/community/
[vcbuildtools]: https://visualstudio.microsoft.com/visual-cpp-build-tools/
[eclipse]: https://www.eclipse.org/downloads/packages/
diff --git a/gradle/debugger/hasPythonPackage.gradle b/gradle/debugger/hasPythonPackage.gradle
index c199cb6f0a..addf5436af 100644
--- a/gradle/debugger/hasPythonPackage.gradle
+++ b/gradle/debugger/hasPythonPackage.gradle
@@ -30,11 +30,52 @@ def checkPythonVersion(String pyCmd) {
}
}
+ext.MIN_PIP_VERSION = [20, 2] // 20.2+
+
+def checkPipVersion(String pyCmd) {
+ try {
+ def stdout = new ByteArrayOutputStream()
+ exec {
+ commandLine pyCmd, "-c", "import pip; print(pip.__version__)"
+ standardOutput = stdout
+ errorOutput = OutputStream.nullOutputStream()
+ }
+ def version = "$stdout".strip();
+ if (version.length() == 0) {
+ println("Warning: python pip not installed (required for build)")
+ }
+ else {
+ println("Found python pip version ${version}")
+ def (majorVer, minorVer) = version.tokenize('.')
+ def major = majorVer.toInteger()
+ def minor = minorVer.toInteger()
+ if (major < MIN_PIP_VERSION[0] || (major == MIN_PIP_VERSION[0] && minor < MIN_PIP_VERSION[1])) {
+ println("Warning: python pip may require upgrade")
+ }
+ }
+ return version
+ }
+ catch (Exception e) {
+ println("Warning: python pip not installed")
+ }
+}
+
ext.SUPPORTED_PY_VERSIONS = ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
def findPython3() {
for (pyCmd in ['py', 'python3', 'python']) {
+ def pyVer = checkPythonVersion(pyCmd)
+ if (pyVer in SUPPORTED_PY_VERSIONS) {
+ println("Using python command: ${pyCmd} (version ${pyVer})")
+ checkPipVersion(pyCmd)
+ return pyCmd
+ }
+ }
+ for (pyVer in SUPPORTED_PY_VERSIONS) {
+ def pyCmd = "python${pyVer}"
if (checkPythonVersion(pyCmd) in SUPPORTED_PY_VERSIONS) {
+ println("Using python command: ${pyCmd}")
+ checkPipVersion(pyCmd)
return pyCmd
}
}
@@ -62,8 +103,6 @@ task assemblePyPackage(type: Copy) {
into "build/pypkg/"
}
-rootProject.tasks.prepDev.dependsOn(assemblePyPackage)
-
task buildPyPackage {
ext.dist = { file("build/pypkg/dist") }
inputs.files(assemblePyPackage)