cleanup; unbundle vagrant plugin #PY-80258 Ready for Merge

GitOrigin-RevId: 43f8dda8114f1d78e43f54d11d43b072fd5e7bda
This commit is contained in:
Aleksandr Sorotskii
2025-06-30 16:07:06 +00:00
committed by intellij-monorepo-bot
parent 4327d7b425
commit 82ae13556e
12 changed files with 10 additions and 85 deletions
@@ -50,7 +50,6 @@ public final class PythonIcons {
/** 16x16 */ public static final @NotNull Icon Ssh = load("icons/com/jetbrains/pythonCore/python/expui/ssh.svg", "icons/com/jetbrains/pythonCore/python/ssh.svg", 1941773502, 0);
/** 16x16 */ public static final @NotNull Icon TemplateRoot = load("icons/com/jetbrains/pythonCore/python/expui/templateRoot.svg", "icons/com/jetbrains/pythonCore/python/templateRoot.svg", 6261950, 0);
/** 16x16 */ public static final @NotNull Icon TensorFlow = load("icons/com/jetbrains/pythonCore/python/tensorFlow.svg", 1673568687, 2);
/** 16x16 */ public static final @NotNull Icon Vagrant = load("icons/com/jetbrains/pythonCore/python/expui/vagrant.svg", "icons/com/jetbrains/pythonCore/python/vagrant.svg", -820295927, 0);
/** 16x16 */ public static final @NotNull Icon ViewAsImage = load("icons/com/jetbrains/pythonCore/python/viewAsImage.svg", -384883859, 2);
/** 16x16 */ public static final @NotNull Icon Virtualenv = load("icons/com/jetbrains/pythonCore/python/expui/virtualEnv.svg", "icons/com/jetbrains/pythonCore/python/virtualenv.svg", 758230626, 0);
}
@@ -1,6 +0,0 @@
<!-- Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.6524 1.40234L9.74837 3.10334H9.74638V3.10534V4.26434L8.00138 8.33434V9.69434L6.84037 10.3683L4.51537 5.13334V4.10834L6.26038 3.10534L3.35238 1.40234L1.60938 2.42034V3.66734L5.53338 13.1973L8.00138 14.6233V11.0423L9.16437 10.3683L9.14937 10.3593L11.4894 5.13334V4.11034V4.10834L14.3954 2.42034L12.6524 1.40234Z" fill="#4682FA"/>
<path d="M8.00175 8.33401L8.00163 9.6943L6.84063 10.3683L4.51562 5.1333V4.1083L6.25035 3.11121L6.25888 3.11431V4.26431L8.00175 8.33401Z" fill="#315FBD"/>
<path d="M8.00163 14.6226V11.0423L9.16463 10.3683L9.14962 10.3593L11.4896 5.1333V4.1083L14.3952 2.42053V3.62988L10.4932 13.1859L8.00163 14.6226Z" fill="#315FBD"/>
</svg>

Before

Width:  |  Height:  |  Size: 928 B

@@ -1,6 +0,0 @@
<!-- Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.6524 1.40234L9.74837 3.10334H9.74638V3.10534V4.26434L8.00138 8.33434V9.69434L6.84037 10.3683L4.51537 5.13334V4.10834L6.26038 3.10534L3.35238 1.40234L1.60938 2.42034V3.66734L5.53338 13.1973L8.00138 14.6233V11.0423L9.16437 10.3683L9.14937 10.3593L11.4894 5.13334V4.11034V4.10834L14.3954 2.42034L12.6524 1.40234Z" fill="#548AF7"/>
<path d="M8.00175 8.33401L8.00163 9.6943L6.84063 10.3683L4.51562 5.1333V4.1083L6.25035 3.11121L6.25888 3.11431V4.26431L8.00175 8.33401Z" fill="#375FAD"/>
<path d="M8.00163 14.6226V11.0423L9.16463 10.3683L9.14962 10.3593L11.4896 5.1333V4.1083L14.3952 2.42053V3.62988L10.4932 13.1859L8.00163 14.6226Z" fill="#375FAD"/>
</svg>

Before

Width:  |  Height:  |  Size: 928 B

@@ -1,8 +0,0 @@
<!-- Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" fill-rule="evenodd" transform="translate(1.5 1.4)">
<polygon fill="#1159CC" points="12.786 2.23 12.786 1.02 9.88 2.71 9.88 3.733 7.555 8.747 6.392 9.549 6.392 13.223 8.884 11.786"/>
<polygon fill="#1159CC" points="6.392 6.934 4.649 2.864 4.649 1.714 4.638 1.71 2.906 2.71 2.906 3.733 5.231 8.968 6.392 8.393"/>
<polygon fill="#127EFF" points="11.043 .002 8.139 1.703 8.137 1.703 8.137 1.705 8.137 1.705 8.137 1.705 8.137 2.864 6.392 6.934 6.392 8.294 5.231 8.968 2.906 3.733 2.906 2.708 4.651 1.705 1.743 .002 0 1.02 0 2.267 3.924 11.797 6.392 13.223 6.392 9.642 7.555 8.968 7.54 8.959 9.88 3.733 9.88 2.71 9.88 2.708 12.786 1.02"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 887 B

@@ -1228,7 +1228,6 @@ python.debugger.attaching=Attaching Debugger
python.rename.processor.override.message=Method {0} of class {1}\noverrides method of class {2}.\nDo you want to rename the base method?
python.rename.processor.property=Do you want to rename the property ''{0}'' instead of its accessor function ''{1}''?
python.configuration.choose.target.to.run=Choose the target to run
python.vagrant.refresh.skeletons=Launch vagrant and refresh skeletons
python.concurrency.visualizer.scroll.end=Scroll to the End
python.template.select.file.type=Select File Type
@@ -235,17 +235,4 @@ suspend fun Sdk.setAssociationToPath(path: String?) {
writeAction {
modificator.commitChanges()
}
}
@ApiStatus.Internal
object PythonSdkAdditionalDataUtils {
@JvmStatic
fun associateSdkWithModulePath(sdk: Sdk, module: Module) {
val sdkModificator = sdk.sdkModificator
val additionalData = sdkModificator.sdkAdditionalData as? PythonSdkAdditionalData ?: return
additionalData.associatedModulePath = module.basePath ?: return
ApplicationManager.getApplication().runWriteAction {
sdkModificator.commitChanges()
}
}
}
@@ -8,7 +8,6 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkAdditionalData;
import com.intellij.openapi.projectRoots.SdkModificator;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.python.community.helpersLocator.PythonHelpersLocator;
@@ -31,7 +30,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.nio.charset.Charset;
import java.util.Collection;
public abstract class PythonRemoteInterpreterManager {
public static final ExtensionPointName<PythonRemoteInterpreterManager> EP_NAME =
@@ -41,8 +39,6 @@ public abstract class PythonRemoteInterpreterManager {
public static final String PYTHON_PREFIX = "python";
public abstract boolean editSdk(@NotNull Project project, @NotNull SdkModificator sdkModificator, @NotNull Collection<Sdk> existingSdks);
public static @Nullable PythonRemoteInterpreterManager getInstance() {
return ContainerUtil.getFirstItem(EP_NAME.getExtensionList());
}
@@ -115,8 +111,6 @@ public abstract class PythonRemoteInterpreterManager {
public abstract String @NotNull [] chooseRemoteFiles(@NotNull Project project, @NotNull PyRemoteSdkAdditionalDataBase data, boolean foldersOnly)
throws ExecutionException, InterruptedException;
public abstract void runVagrant(@NotNull String vagrantFolder, @Nullable String machineName) throws ExecutionException;
public static class PyHelpersNotReadyException extends RuntimeException {
public PyHelpersNotReadyException(Throwable cause) {
super("Python helpers are not copied yet to the remote host. Please wait until remote interpreter initialization finishes.", cause);
@@ -97,6 +97,7 @@ fun configurePythonSdk(project: Project, module: Module, sdk: Sdk) {
module.pythonSdk = sdk
module.excludeInnerVirtualEnv(sdk)
}
// TODO: PythonInterpreterService: get system pythons
/**
* @param context used to get [BASE_DIR] in [VirtualEnvSdkFlavor.suggestLocalHomePaths]
@@ -144,24 +145,20 @@ fun resetSystemWideSdksDetectors() {
}
@Internal
fun detectVirtualEnvs(module: Module?, existingSdks: List<Sdk>, context: UserDataHolder): List<PyDetectedSdk> =
filterSuggestedPaths(VirtualEnvSdkFlavor.getInstance(), existingSdks, module, context)
@Internal
fun filterSharedCondaEnvs(module: Module?, existingSdks: List<Sdk>): List<Sdk> {
return existingSdks.filter { it.sdkType is PythonSdkType && PythonSdkUtil.isConda(it) && !it.isAssociatedWithAnotherModule(module) }
return existingSdks.filter { PythonSdkUtil.isPythonSdk(it) && PythonSdkUtil.isConda(it) && !it.isAssociatedWithAnotherModule(module) }
}
@Internal
fun filterAssociatedSdks(module: Module, existingSdks: List<Sdk>): List<Sdk> {
return existingSdks.filter { it.sdkType is PythonSdkType && it.isAssociatedWithModule(module) }
return existingSdks.filter { PythonSdkUtil.isPythonSdk(it) && it.isAssociatedWithModule(module) }
}
@Internal
fun detectAssociatedEnvironments(module: Module, existingSdks: List<Sdk>, context: UserDataHolder): List<PyDetectedSdk> =
detectVirtualEnvs(module, existingSdks, context).filter { it.isAssociatedWithModule(module) }
@@ -175,7 +172,6 @@ fun createSdkByGenerateTask(
): Sdk = createSdkByGenerateTask(generateSdkHomePath, existingSdks, baseSdk, associatedProjectPath, suggestedSdkName, null)
@Internal
fun createSdkByGenerateTask(
generateSdkHomePath: Task.WithResult<String, ExecutionException>,
existingSdks: List<Sdk>,
@@ -395,7 +391,6 @@ var Project.pythonSdk: Sdk?
}
@Internal
fun Module.excludeInnerVirtualEnv(sdk: Sdk) {
val root = getInnerVirtualEnvRoot(sdk) ?: return
@@ -472,7 +467,6 @@ private val Sdk.sitePackagesDirectory: VirtualFile?
val Sdk.sdkFlavor: PythonSdkFlavor<*> get() = getOrCreateAdditionalData().flavor
@Internal
fun Sdk.isLocatedInsideModule(module: Module?): Boolean {
val moduleDir = module?.baseDir
val sdkDir = homeDirectory
@@ -563,7 +557,6 @@ val Sdk.remoteSourcesLocalPath: Path
* Configures [targetCommandLineBuilder] (sets a binary path and other stuff) so it could run python on this target
*/
@Internal
fun Sdk.configureBuilderToRunPythonOnTarget(targetCommandLineBuilder: TargetedCommandLineBuilder) {
getOrCreateAdditionalData().flavorAndData.data.prepareTargetCommandLine(this, targetCommandLineBuilder)
}
@@ -1,7 +1,6 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.jetbrains.python.sdk;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.target.TargetEnvironmentConfiguration;
import com.intellij.ide.DataManager;
@@ -22,13 +21,11 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.HtmlBuilder;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.reference.SoftReference;
import com.intellij.remote.ExceptionFix;
import com.intellij.remote.VagrantNotStartedException;
import com.intellij.remote.ext.LanguageCaseCollector;
import com.intellij.util.Consumer;
import com.intellij.util.ExceptionUtil;
@@ -79,9 +76,6 @@ public final class PythonSdkType extends SdkType {
private static final Logger LOG = Logger.getInstance(PythonSdkType.class);
private static final int MINUTE = 60 * 1000; // 60 seconds, used with script timeouts
private static final @NonNls String SKELETONS_TOPIC = "Skeletons";
private static final Key<WeakReference<Component>> SDK_CREATOR_COMPONENT_KEY = Key.create("#com.jetbrains.python.sdk.creatorComponent");
@@ -372,28 +366,7 @@ public final class PythonSdkType extends SdkType {
public static void notifyRemoteSdkSkeletonsFail(final InvalidSdkException e, final @Nullable Runnable restartAction) {
NotificationListener notificationListener;
String notificationMessage;
if (e.getCause() instanceof VagrantNotStartedException cause) {
notificationListener =
(notification, event) -> {
final PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance();
if (manager != null) {
try {
manager.runVagrant(cause.getVagrantFolder(), cause.getMachineName());
}
catch (ExecutionException e1) {
throw new RuntimeException(e1);
}
}
if (restartAction != null) {
restartAction.run();
}
};
notificationMessage = new HtmlBuilder()
.append(e.getMessage())
.appendLink("#", PyBundle.message("python.vagrant.refresh.skeletons"))
.toString();
}
else if (ExceptionUtil.causedBy(e, ExceptionFix.class)) {
if (ExceptionUtil.causedBy(e, ExceptionFix.class)) {
final ExceptionFix fix = ExceptionUtil.findCause(e, ExceptionFix.class);
notificationListener =
(notification, event) -> {
@@ -11,8 +11,8 @@ import com.jetbrains.python.packaging.common.PythonPackage;
import com.jetbrains.python.packaging.management.RequirementsProviderType;
import com.jetbrains.python.packaging.management.TestPythonPackageManager;
import com.jetbrains.python.psi.LanguageLevel;
import com.jetbrains.python.sdk.PythonSdkAdditionalDataUtils;
import com.jetbrains.python.sdk.PythonSdkUtil;
import com.jetbrains.python.sdk.SdksKt;
import com.jetbrains.python.sdk.pipenv.PipenvFilesUtilsKt;
import org.jetbrains.annotations.NotNull;
@@ -34,7 +34,7 @@ public class PyPackageRequirementsInspectionTest extends PyInspectionTestCase {
public void setUp() throws Exception {
super.setUp();
final Sdk sdk = PythonSdkUtil.findPythonSdk(myFixture.getModule());
PythonSdkAdditionalDataUtils.associateSdkWithModulePath(sdk, myFixture.getModule());
SdksKt.setAssociationToModuleAsync(sdk, myFixture.getModule());
assertNotNull(sdk);
PyPIPackageCache.reload(List.of("opster", "clevercss", "django", "test3", "pyzmq", "markdown", "pytest", "django-simple-captcha"));
@@ -25,8 +25,8 @@ import com.jetbrains.python.psi.LanguageLevel;
import com.jetbrains.python.psi.PyCallExpression;
import com.jetbrains.python.psi.PyExpression;
import com.jetbrains.python.psi.PyFile;
import com.jetbrains.python.sdk.PythonSdkAdditionalDataUtils;
import com.jetbrains.python.sdk.PythonSdkUtil;
import com.jetbrains.python.sdk.SdksKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -44,7 +44,7 @@ public class PyPackageUtilTest extends PyTestCase {
myFixture.copyDirectoryToProject("packaging/PyPackageUtil/" + getTestName(false), "");
Module module = myFixture.getModule();
Sdk sdk = PythonSdkUtil.findPythonSdk(module);
PythonSdkAdditionalDataUtils.associateSdkWithModulePath(sdk, module);
SdksKt.setAssociationToModuleAsync(sdk, module);
}
public void testAbsentSetupPyReading() {
@@ -13,8 +13,8 @@ import com.intellij.testFramework.registerServiceInstance
import com.jetbrains.python.fixtures.PyTestCase
import com.jetbrains.python.packaging.common.PythonPackage
import com.jetbrains.python.packaging.management.TestPythonPackageManagerService
import com.jetbrains.python.sdk.PythonSdkAdditionalDataUtils
import com.jetbrains.python.sdk.PythonSdkUtil
import com.jetbrains.python.sdk.setAssociationToModuleAsync
import org.easymock.EasyMock
class PyRequirementsGenerationTest : PyTestCase() {
@@ -57,7 +57,7 @@ class PyRequirementsGenerationTest : PyTestCase() {
) {
val module = myFixture.getModule()
val sdk = PythonSdkUtil.findPythonSdk(module)
PythonSdkAdditionalDataUtils.associateSdkWithModulePath(sdk!!, module)
sdk!!.setAssociationToModuleAsync(module)
val settings = PyPackageRequirementsSettings.getInstance(myFixture.module)
val oldVersionSpecifier = settings.versionSpecifier