From 41f007b348bbe2b27e50ebedc6c7b7e43ce8956c Mon Sep 17 00:00:00 2001 From: Hugo Saporetti Junior Date: Thu, 3 Oct 2024 16:22:48 -0300 Subject: [PATCH] Fix project.ext.python --- gradle/dependencies.gradle | 34 +++++++++++++++++++++++++++++++--- gradle/python.gradle | 2 +- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index e1cd7d82..914897e9 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -7,10 +7,38 @@ */ import org.gradle.internal.os.OperatingSystem; +/* Detect the installed python. */ +String detectPython() { + def pythonHome = System.getenv('PYTHON_HOME') ?: null + if (pythonHome != null) { + return pythonHome + '/python3' + } + def output = new ByteArrayOutputStream() + exec { + commandLine 'command', '-v', 'python3' + standardOutput = output + } + pythonHome = output.toString() + assert pythonHome != null, "Could not find any installed python3 version" + exec { + commandLine pythonHome, '--version' + standardOutput = output + } + pythonVersion = output.toString() + + println("-=- Python " + pythonVersion + " -=-") + + return pythonHome +} + /* Project file definitions */ -project.ext.depsFile = "$project.projectDir/dependencies.hspd" -project.ext.reqsFile = "$project.projectDir/src/main/requirements.txt" -project.ext.os = OperatingSystem.current().getName() +ext { + depsFile = "$project.projectDir/dependencies.hspd" + reqsFile = "$project.projectDir/src/main/requirements.txt" + os = OperatingSystem.current().getName() + python = detectPython() + pyrcc = 'pyrcc5' +} /* Version compatibility mode map */ def modesMap = [ diff --git a/gradle/python.gradle b/gradle/python.gradle index 6a91b568..bacf1b30 100644 --- a/gradle/python.gradle +++ b/gradle/python.gradle @@ -109,7 +109,7 @@ task compileQrc(type: Task) { }.each { File file -> if (verbose) println "Compiling Qt Resource -> ${file.name}" exec { - commandLine project.pyrcc, '-m', 'py_compile', file.path + commandLine project.pyrcc, file.path } } }