mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-27954 Don't assume that "lib" dir of venv can contain only pythonX.Y
because some packages like mypy can actually install their resources there, and it breaks our detection of built-in and third-party packages. On Windows this check doesn't make sense since there site-packages and copied stdlib modules lie directly inside "Lib", i.e. there is no additional level of nesting.
This commit is contained in:
@@ -24,10 +24,12 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.FileIndexFacade;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypeShed;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -172,8 +174,11 @@ public class PyProjectScopeBuilder extends ProjectScopeBuilderImpl {
|
||||
if (root != null) {
|
||||
File libRoot = new File(root, "lib");
|
||||
File[] versionRoots = libRoot.listFiles();
|
||||
if (versionRoots != null && versionRoots.length == 1) {
|
||||
libRoot = versionRoots[0];
|
||||
if (versionRoots != null && !SystemInfo.isWindows) {
|
||||
final File versionRoot = ContainerUtil.find(versionRoots, file -> file.isDirectory() && file.getName().startsWith("python"));
|
||||
if (versionRoot != null) {
|
||||
libRoot = versionRoot;
|
||||
}
|
||||
}
|
||||
for (VirtualFile file : classVFiles) {
|
||||
if (FileUtil.pathsEqual(file.getPath(), libRoot.getPath())) {
|
||||
|
||||
Reference in New Issue
Block a user