fixed PY-13531 Stop executing $world when it looks like a python binary.

This commit is contained in:
Ekaterina Tuzova
2014-11-17 14:50:05 +03:00
parent 3070183594
commit 7a2e2cdbe8
3 changed files with 9 additions and 7 deletions
@@ -17,10 +17,13 @@ package com.jetbrains.python.sdk.flavors;
import org.jetbrains.annotations.NotNull;
import java.util.regex.Pattern;
/**
* @author yole
*/
public abstract class CPythonSdkFlavor extends PythonSdkFlavor {
public final static Pattern PYTHON_RE = Pattern.compile("python-?(\\d\\.\\d)?|python-?(\\d)?");
@NotNull
@Override
public String getName() {
@@ -31,7 +31,7 @@ public class UnixPythonSdkFlavor extends CPythonSdkFlavor {
private UnixPythonSdkFlavor() {
}
private final static String[] NAMES = new String[]{"python", "jython", "pypy"};
private final static String[] NAMES = new String[]{"jython", "pypy"};
public static UnixPythonSdkFlavor INSTANCE = new UnixPythonSdkFlavor();
@@ -52,9 +52,9 @@ public class UnixPythonSdkFlavor extends CPythonSdkFlavor {
VirtualFile[] suspects = rootDir.getChildren();
for (VirtualFile child : suspects) {
if (!child.isDirectory()) {
final String childName = child.getName();
final String childName = child.getName().toLowerCase();
for (String name : NAMES) {
if (childName.startsWith(name)) {
if (childName.startsWith(name) || PYTHON_RE.matcher(childName).matches()) {
String childPath = child.getPath();
if (FileSystemUtil.isSymLink(childPath)) {
childPath = FileSystemUtil.resolveSymLink(childPath);
@@ -41,8 +41,7 @@ import java.util.List;
public class VirtualEnvSdkFlavor extends CPythonSdkFlavor {
private VirtualEnvSdkFlavor() {
}
private final static String[] NAMES = new String[]{"python", "jython", "pypy", "python.exe", "jython.bat", "pypy.exe"};
private final static String[] NAMES = new String[]{"jython", "pypy", "python.exe", "jython.bat", "pypy.exe"};
public static VirtualEnvSdkFlavor INSTANCE = new VirtualEnvSdkFlavor();
@@ -107,7 +106,7 @@ public class VirtualEnvSdkFlavor extends CPythonSdkFlavor {
private static String findInterpreter(VirtualFile dir) {
for (VirtualFile child : dir.getChildren()) {
if (!child.isDirectory()) {
final String childName = child.getName();
final String childName = child.getName().toLowerCase();
for (String name : NAMES) {
if (SystemInfo.isWindows) {
if (childName.equals(name)) {
@@ -115,7 +114,7 @@ public class VirtualEnvSdkFlavor extends CPythonSdkFlavor {
}
}
else {
if (childName.startsWith(name)) {
if (childName.startsWith(name) || PYTHON_RE.matcher(childName).matches()) {
if (!childName.endsWith("-config")) {
return child.getPath();
}