mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 11:31:43 +00:00
GP-0: Improving python build error reporting (Closes #7036)
This commit is contained in:
parent
ddf1efd486
commit
3558fe59a4
@ -56,7 +56,9 @@ task installJPype(type: Exec) {
|
||||
File binRepoDir = file("${BIN_REPO}/ExternalPyWheels")
|
||||
def dir = depsDir.exists() ? depsDir : binRepoDir
|
||||
|
||||
commandLine "$PYTHON3_VENV", "-m", "pip", "install", "--no-index", "-f", "$dir", "JPype1"
|
||||
doFirst {
|
||||
commandLine "$PYTHON3_VENV", "-m", "pip", "install", "--no-index", "-f", "$dir", "JPype1"
|
||||
}
|
||||
}
|
||||
|
||||
// Install PyGhidra in editable mode to the development virtual environment
|
||||
@ -67,10 +69,12 @@ task installEditablePyGhidra(type: Exec) {
|
||||
File binRepoDir = file("${BIN_REPO}/ExternalPyWheels")
|
||||
def dir = depsDir.exists() ? depsDir : binRepoDir
|
||||
|
||||
commandLine "$PYTHON3_VENV", "-m", "pip", "install", "-e", "src/main/py", "--no-index", "-f", "$dir"
|
||||
doFirst {
|
||||
commandLine "$PYTHON3_VENV", "-m", "pip", "install", "-e", "src/main/py", "--no-index", "-f", "$dir"
|
||||
}
|
||||
}
|
||||
|
||||
if (findPython3(false, false)) {
|
||||
if (findPython3(false)) {
|
||||
rootProject.prepDev.dependsOn installEditablePyGhidra
|
||||
}
|
||||
|
||||
|
10
build.gradle
10
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(true, true)
|
||||
project.ext.PYTHON3 = findPython3(true)
|
||||
project.ext.PYTHON_DEPS = new HashSet<String>()
|
||||
|
||||
/*********************************************************************************
|
||||
@ -204,7 +204,7 @@ def checkPip(List<String> pyCmd, boolean shouldPrint) {
|
||||
}
|
||||
}
|
||||
|
||||
def findPython3(boolean useDefault, boolean shouldPrint) {
|
||||
def findPython3(boolean shouldPrint) {
|
||||
def pyCmds = [['py'], ['python3'], ['python']]
|
||||
pyCmds += SUPPORTED_PY_VERSIONS.collectMany { [["python$it"], ["py", "-$it"]] }
|
||||
for (pyCmd in pyCmds) {
|
||||
@ -218,14 +218,12 @@ def findPython3(boolean useDefault, boolean shouldPrint) {
|
||||
}
|
||||
}
|
||||
|
||||
// Don't fail until task execution. Just let "python3" fail.
|
||||
// Force use of non-existent python3.9 instead of unsupported python version
|
||||
// which should fail if a python build is performed.
|
||||
if (shouldPrint) {
|
||||
println("Warning: Supported Python ${SUPPORTED_PY_VERSIONS} not found (required for build)")
|
||||
}
|
||||
|
||||
return useDefault ? 'python3.9' : null
|
||||
// Don't fail until task execution. Just retun null, which can be gracefully handled later.
|
||||
return null
|
||||
}
|
||||
|
||||
/******************************************************************************************
|
||||
|
@ -48,6 +48,10 @@ task buildPyPackage {
|
||||
outputs.dir(dist)
|
||||
|
||||
doLast {
|
||||
if (rootProject.PYTHON3 == null) {
|
||||
throw new GradleException("A supported version of Python ${SUPPORTED_PY_VERSIONS} was not found!")
|
||||
}
|
||||
|
||||
File setuptools = project(":Debugger-rmi-trace").findPyDep(".")
|
||||
exec {
|
||||
workingDir { "build/pypkg" }
|
||||
|
@ -271,6 +271,11 @@ task createGhidraStubsWheel {
|
||||
|
||||
doLast {
|
||||
File setuptools = project(":Debugger-rmi-trace").findPyDep(".")
|
||||
|
||||
if (rootProject.PYTHON3 == null) {
|
||||
throw new GradleException("A supported version of Python ${SUPPORTED_PY_VERSIONS} was not found!")
|
||||
}
|
||||
|
||||
exec {
|
||||
workingDir { cwd.toString() }
|
||||
commandLine rootProject.PYTHON3
|
||||
|
@ -24,11 +24,17 @@ task createPythonVirtualEnvironment(type: Exec) {
|
||||
def suffix = isCurrentWindows() ? ".exe" : "3"
|
||||
project.ext.PYTHON3_VENV = "${rootProject.projectDir}/${venvDir}/${binDir}/python${suffix}"
|
||||
project.ext.PIP3_VENV = "${rootProject.projectDir}/${venvDir}/${binDir}/pip${suffix}"
|
||||
|
||||
commandLine rootProject.PYTHON3
|
||||
args "-m", "venv", venvDir, "--copies"
|
||||
|
||||
doFirst {
|
||||
if (rootProject.PYTHON3 == null) {
|
||||
throw new GradleException("A supported version of Python ${SUPPORTED_PY_VERSIONS} was not found!")
|
||||
}
|
||||
|
||||
commandLine rootProject.PYTHON3
|
||||
args "-m", "venv", venvDir, "--copies"
|
||||
}
|
||||
}
|
||||
|
||||
if (findPython3(false, false)) {
|
||||
if (findPython3(false)) {
|
||||
rootProject.prepDev.dependsOn createPythonVirtualEnvironment
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user