cleanup [python]: Load randomBinary in lazy manner.

Exception in `PathEnvironmentVariableUtil` shouldn't lead to class initialization exception

(cherry picked from commit 0d4748688f1e259ab3c00f770de63df5e3a66559)

GitOrigin-RevId: e445dcf09106d955caea5f27cc59284947895a12
This commit is contained in:
Ilya.Kazakevich
2026-06-28 18:45:35 +00:00
committed by intellij-monorepo-bot
parent 0adebecef2
commit 0e36c07080
@@ -18,14 +18,15 @@ import kotlin.io.path.Path
/**
* Binary that isn't python. To be used to test validation.
*/
val randomBinary: PythonBinary = Path(
if (SystemInfoRt.isWindows) {
// ftp.exe is faster than cmd.exe and powershell.exe
PathEnvironmentVariableUtil.findInPath("ftp.exe")?.path ?: error("No ftp on Windows?")
}
else {
"/bin/sh"
})
val randomBinary: PythonBinary
get() = Path(
if (SystemInfoRt.isWindows) {
// ftp.exe is faster than cmd.exe and powershell.exe
PathEnvironmentVariableUtil.findInPath("ftp.exe")?.path ?: error("No ftp on Windows?")
}
else {
"/bin/sh"
})
/**
* Fails if [this] is not [Result.Failure]