boolean (@Nullable VirtualFile file, @NotNull String path, @NotNull VirtualFile libDir, @NotNull Sdk sdk, boolean checkOnRemoteFS) { final VirtualFile originLibDir; final String originLibDirPath; if (checkOnRemoteFS) { originLibDir = libDir; originLibDirPath = mapToRemote(originLibDir.getPath(), sdk); } else { // Normalize the path to the lib directory on local FS originLibDir = ObjectUtils.notNull(libDir.getCanonicalFile(), libDir); originLibDirPath = originLibDir.getPath(); } // This check is more brittle and thus used as a fallback measure if (checkOnRemoteFS || file == null) { final String normalizedLidDirPath = FileUtil.toSystemIndependentName(originLibDirPath); final String sitePackagesPath = normalizedLidDirPath + "/" + PyNames.SITE_PACKAGES; final String normalizedPath = FileUtil.toSystemIndependentName(path); return FileUtil.startsWith(normalizedPath, normalizedLidDirPath) && !FileUtil.startsWith(normalizedPath, sitePackagesPath); } else if (VfsUtilCore.isAncestor(originLibDir, file, false)) { final VirtualFile sitePackagesDir = originLibDir.findChild(PyNames.SITE_PACKAGES); return sitePackagesDir == null || !VfsUtilCore.isAncestor(sitePackagesDir, file, false); } return false; }