Skip to content

Commit

Permalink
Fix project.ext.python
Browse files Browse the repository at this point in the history
  • Loading branch information
yorevs committed Oct 3, 2024
1 parent 9d60ede commit 41f007b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
34 changes: 31 additions & 3 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion gradle/python.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit 41f007b

Please sign in to comment.