mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
python interpreter should be at least executable but not necessarily called python; PY-60259; PY-11992
(cherry picked from commit a9dd773947b75e850c1e74e209bec9330ae8d74f) IJ-MR-143222 GitOrigin-RevId: 16f075b18210dbd73a8e04e86282064048c06b99
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ba81251f81
commit
1cb0659dad
@@ -330,7 +330,7 @@ public abstract class PythonSdkFlavor<D extends PyFlavorData> {
|
||||
* It only validates path for local target, hence use {@link #sdkSeemsValid(Sdk, PyFlavorData, TargetEnvironmentConfiguration)} instead
|
||||
*/
|
||||
public boolean isValidSdkPath(@NotNull Path path) {
|
||||
return StringUtil.toLowerCase(FileUtilRt.getNameWithoutExtension(path.getFileName().toString())).contains("python");
|
||||
return Files.exists(path) && Files.isExecutable(path);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -11,7 +11,11 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypeShed;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.sdk.PythonSdkAdditionalData;
|
||||
import com.jetbrains.python.sdk.PythonSdkUtil;
|
||||
import com.jetbrains.python.sdk.flavors.PyFlavorAndData;
|
||||
import com.jetbrains.python.sdk.flavors.PyFlavorData;
|
||||
import com.jetbrains.python.sdk.flavors.VirtualEnvSdkFlavor;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -55,6 +59,7 @@ public final class PythonMockSdk {
|
||||
Sdk sdk = ProjectJdkTable.getInstance().createSdk(sdkName, sdkType);
|
||||
SdkModificator sdkModificator = sdk.getSdkModificator();
|
||||
sdkModificator.setHomePath(sdkPath + "/bin/python");
|
||||
sdkModificator.setSdkAdditionalData(new PythonSdkAdditionalData(new PyFlavorAndData(PyFlavorData.Empty.INSTANCE, VirtualEnvSdkFlavor.getInstance())));
|
||||
sdkModificator.setVersionString(toVersionString(level));
|
||||
|
||||
createRoots(sdkPath, level).forEach(vFile -> {
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.intellij.testFramework.assertions.Assertions.assertThat
|
||||
import com.intellij.testFramework.rules.ProjectModelRule
|
||||
import com.intellij.workspaceModel.ide.legacyBridge.GlobalSdkTableBridge
|
||||
import com.jetbrains.python.PyNames
|
||||
import com.jetbrains.python.PythonLanguage
|
||||
import com.jetbrains.python.PythonMockSdk
|
||||
import com.jetbrains.python.PythonPluginDisposable
|
||||
import com.jetbrains.python.configuration.PyConfigurableInterpreterList
|
||||
@@ -69,11 +70,13 @@ class PySdkPathsTest {
|
||||
fun userAddedIsModuleRoot() {
|
||||
val (module, moduleRoot) = createModule()
|
||||
|
||||
mockPythonPluginDisposable()
|
||||
|
||||
val sdk = PythonMockSdk.create().also {
|
||||
registerSdk(it)
|
||||
module.pythonSdk = it
|
||||
}
|
||||
mockPythonPluginDisposable()
|
||||
|
||||
runWriteActionAndWait { sdk.getOrCreateAdditionalData() }.apply { setAddedPathsFromVirtualFiles(setOf(moduleRoot)) }
|
||||
|
||||
updateSdkPaths(sdk)
|
||||
@@ -142,25 +145,16 @@ class PySdkPathsTest {
|
||||
// emulates com.jetbrains.python.configuration.PythonSdkDetailsDialog.ShowPathButton.actionPerformed
|
||||
|
||||
val (module, moduleRoot) = createModule()
|
||||
|
||||
val sdkPath = createVenvStructureInModule(moduleRoot).path
|
||||
|
||||
val userAddedPath = createSubdir(moduleRoot)
|
||||
|
||||
mockPythonPluginDisposable()
|
||||
|
||||
val pythonVersion = LanguageLevel.getDefault().toPythonVersion()
|
||||
val sdk = ProjectJdkTable.getInstance().createSdk("Mock ${PyNames.PYTHON_SDK_ID_NAME} $pythonVersion", PythonSdkType.getInstance())
|
||||
sdk.sdkModificator.apply {
|
||||
homePath = "$sdkPath/bin/python"
|
||||
versionString = pythonVersion
|
||||
runWriteActionAndWait {
|
||||
commitChanges()
|
||||
sdk.getOrCreateAdditionalData()
|
||||
}
|
||||
}
|
||||
val sdk = PythonMockSdk.create(pythonVersion)
|
||||
registerSdk(sdk)
|
||||
module.pythonSdk = sdk
|
||||
|
||||
IndexingTestUtil.waitUntilIndexesAreReady(module.project)
|
||||
sdk.putUserData(PythonSdkType.MOCK_PY_VERSION_KEY, pythonVersion)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user