SDK roots must be only classes, not sources (PY-2891)

This commit is contained in:
Dmitry Jemerov
2011-03-22 19:12:08 +01:00
parent 19534ecd93
commit 555870ef1b
2 changed files with 6 additions and 3 deletions
@@ -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() {