mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SDK roots must be only classes, not sources (PY-2891)
This commit is contained in:
@@ -494,7 +494,6 @@ public class PythonSdkType extends SdkType {
|
||||
if (SystemInfo.isLinux) {
|
||||
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath("/usr/lib/python-django");
|
||||
if (file != null){
|
||||
sdkModificator.addRoot(file, OrderRootType.SOURCES);
|
||||
sdkModificator.addRoot(file, OrderRootType.CLASSES);
|
||||
}
|
||||
}
|
||||
@@ -510,7 +509,9 @@ public class PythonSdkType extends SdkType {
|
||||
child = JarFileSystem.getInstance().getJarRootForLocalFile(child);
|
||||
}
|
||||
if (child != null) {
|
||||
sdkModificator.addRoot(child, OrderRootType.SOURCES);
|
||||
// NOTE: Files marked as library sources are not considered part of project source. Since the directory of the project the
|
||||
// user is working on is included in PYTHONPATH with many configurations (e.g. virtualenv), we must not mark SDK paths as
|
||||
// library sources, only as classes.
|
||||
sdkModificator.addRoot(child, OrderRootType.CLASSES);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ public class PythonSdkUpdater implements ProjectComponent {
|
||||
|
||||
private static void updateSdkPath(Sdk sdk, List<String> sysPath) {
|
||||
final List<VirtualFile> oldRoots = Arrays.asList(sdk.getRootProvider().getFiles(OrderRootType.CLASSES));
|
||||
final VirtualFile[] sourceRoots = sdk.getRootProvider().getFiles(OrderRootType.SOURCES);
|
||||
PythonSdkAdditionalData additionalData = sdk.getSdkAdditionalData() instanceof PythonSdkAdditionalData
|
||||
? (PythonSdkAdditionalData) sdk.getSdkAdditionalData()
|
||||
: null;
|
||||
@@ -116,11 +117,12 @@ public class PythonSdkUpdater implements ProjectComponent {
|
||||
newRoots.add(root);
|
||||
}
|
||||
}
|
||||
if (!newRoots.isEmpty()) {
|
||||
if (!newRoots.isEmpty() || sourceRoots.length > 0) {
|
||||
final SdkModificator modificator = sdk.getSdkModificator();
|
||||
for (String root : newRoots) {
|
||||
PythonSdkType.addSdkRoot(modificator, root);
|
||||
}
|
||||
modificator.removeRoots(OrderRootType.SOURCES);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user