mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-19 16:40:38 -09:00
GP-4367: Package dbgmodel (ghidradbg) better
This commit is contained in:
@@ -14,6 +14,39 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
def checkPythonVersion(String pyCmd) {
|
||||
try {
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine pyCmd, "-c", "import sys; print('{0}.{1}'.format(*sys.version_info))"
|
||||
standardOutput = stdout
|
||||
}
|
||||
def version = "$stdout".strip()
|
||||
println "$pyCmd is version $version"
|
||||
return version
|
||||
}
|
||||
catch (Exception e) {
|
||||
println "Could not run $pyCmd: $e"
|
||||
return "ABSENT"
|
||||
}
|
||||
}
|
||||
|
||||
ext.SUPPORTED_PY_VERSIONS = ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
|
||||
|
||||
def findPython3() {
|
||||
for (pyCmd in ['python3', 'python']) {
|
||||
if (checkPythonVersion(pyCmd) in SUPPORTED_PY_VERSIONS) {
|
||||
println "Using $pyCmd"
|
||||
return pyCmd
|
||||
}
|
||||
}
|
||||
println "Could not find compatible Python 3"
|
||||
// Don't fail until task execution. Just let "python3" fail.
|
||||
return 'python3'
|
||||
}
|
||||
|
||||
ext.PYTHON3 = findPython3()
|
||||
|
||||
task assemblePyPackage(type: Copy) {
|
||||
from "src/main/py"
|
||||
into "build/pypkg/"
|
||||
@@ -27,7 +60,7 @@ task buildPyPackage(type: Exec) {
|
||||
outputs.dir(dist)
|
||||
|
||||
workingDir { "build/pypkg" }
|
||||
commandLine "python3", "-m", "build"
|
||||
commandLine PYTHON3, "-m", "build"
|
||||
}
|
||||
|
||||
// At the moment, any module with a python package also distributes it.
|
||||
|
||||
Reference in New Issue
Block a user