diff --git a/utils/spdx/src/main/kotlin/Utils.kt b/utils/spdx/src/main/kotlin/Utils.kt index 876f8ecf257f9..282291eea1032 100644 --- a/utils/spdx/src/main/kotlin/Utils.kt +++ b/utils/spdx/src/main/kotlin/Utils.kt @@ -49,7 +49,11 @@ val scanCodeLicenseTextDir by lazy { val pythonBinDir = listOf("bin", "Scripts") val scanCodeBaseDir = scanCodeExeDir?.takeUnless { it.name in pythonBinDir } ?: scanCodeExeDir?.parentFile - scanCodeBaseDir?.walkTopDown()?.find { it.isDirectory && it.endsWith("licensedcode/data/licenses") } + scanCodeBaseDir?.walkTopDown()?.find { it.isDirectory && it.endsWith("licensedcode/data/licenses") } ?: + // Fallback: In case a Python Version Management tool like Pyenv is used, the directory structure differs. + scanCodeBaseDir?.parentFile?.walkTopDown() + ?.onEnter { dir -> dir != scanCodeBaseDir } + ?.find { it.isDirectory && it.endsWith("licensedcode/data/licenses") } } /**