mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-01 00:04:57 +08:00
GP-4570 revisions to buildPyPackage task
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user