@@ -25,7 +25,6 @@ import kotlinx.coroutines.runBlocking
25
25
import org.jetbrains.kotlin.idea.util.application.runWriteAction
26
26
import org.jetbrains.kotlin.idea.util.module
27
27
import org.jetbrains.kotlin.idea.util.projectStructure.sdk
28
- import org.jetbrains.kotlin.konan.file.File
29
28
import org.utbot.common.PathUtil.toPath
30
29
import org.utbot.common.appendHtmlLine
31
30
import org.utbot.framework.UtSettings
@@ -335,7 +334,8 @@ fun getDirectoriesForSysPath(
335
334
file.fromImports.forEach { importTarget ->
336
335
importTarget.resolveImportSourceCandidates().forEach {
337
336
val directory = it.parent
338
- if (directory is PsiDirectory ) {
337
+ val isRelativeImport = importTarget.relativeLevel > 0 // If we have `from . import a` we don't need to add syspath
338
+ if (directory is PsiDirectory && ! isRelativeImport) {
339
339
// If we have `from a.b.c import d` we need to add syspath to module `a` only
340
340
val additionalLevel = importTarget.importSourceQName?.componentCount?.dec() ? : 0
341
341
directory.topParent(additionalLevel)?.let { dir ->
@@ -347,7 +347,9 @@ fun getDirectoriesForSysPath(
347
347
348
348
// Select modules only from this project but not from installation directory
349
349
importedPaths.forEach {
350
- if (it.isProjectSubmodule(ancestor) && ! it.path.split(File .separator).contains(" site-packages" )) {
350
+ val path = it.toNioPath()
351
+ val hasSitePackages = (0 until(path.nameCount)).any { i -> path.subpath(i, i+ 1 ).toString() == " site-packages" }
352
+ if (it.isProjectSubmodule(ancestor) && ! hasSitePackages) {
351
353
sources.add(it)
352
354
}
353
355
}
0 commit comments