select Python 2 interpreter when selecting a project type that doesn't support Python 3; report Python 3 as incompatible when creating App Engine project

This commit is contained in:
Dmitry Jemerov
2012-12-18 20:19:46 +01:00
parent 1a4c24f997
commit ff8d993f4f
3 changed files with 10 additions and 0 deletions
@@ -13,4 +13,6 @@ public interface PyFrameworkProjectGenerator<T> extends DirectoryProjectGenerato
boolean isFrameworkInstalled(Project project, Sdk sdk);
boolean acceptsRemoteSdk();
boolean supportsPython3();
}
@@ -11,10 +11,17 @@ import java.util.Comparator;
* @author yole
*/
public class PreferredSdkComparator implements Comparator<Sdk> {
public static PreferredSdkComparator INSTANCE = new PreferredSdkComparator();
@Override
public int compare(Sdk o1, Sdk o2) {
final PythonSdkFlavor flavor1 = PythonSdkFlavor.getFlavor(o1);
final PythonSdkFlavor flavor2 = PythonSdkFlavor.getFlavor(o2);
int venv1weight = PythonSdkType.isVirtualEnv(o1) ? 0 : 1;
int venv2weight = PythonSdkType.isVirtualEnv(o2) ? 0 : 1;
if (venv1weight != venv2weight) {
return venv2weight - venv1weight;
}
int flavor1weight = flavor1 instanceof CPythonSdkFlavor ? 1 : 0;
int flavor2weight = flavor2 instanceof CPythonSdkFlavor ? 1 : 0;
if (flavor1weight != flavor2weight) {
@@ -801,6 +801,7 @@ public class PythonSdkType extends SdkType {
return moduleSDK;
}
List<Sdk> allSdks = getAllSdks();
Collections.sort(allSdks, PreferredSdkComparator.INSTANCE);
for (Sdk sdk : allSdks) {
if (!getLanguageLevelForSdk(sdk).isPy3K()) {
return sdk;