mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
PY-66252 Introduce a new registry key "disable.python.cache.update" to conditionally disable automatic updating of PyPI package cache and ranking on project startup.
Delete unnecessary checks of project-level python. (cherry picked from commit 7b38138885ac7036895ff6c4dcb9f86358d1ecd5) IJ-MR-148661 GitOrigin-RevId: 7bb045be17944f51224fd774b3db67f21a510a51
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9a50d834e7
commit
329fa5cf88
@@ -639,6 +639,11 @@ The Python plug-in provides smart editing for Python scripts. The feature set of
|
||||
defaultValue="[IN_EXPERIMENT*|ENABLED|DISABLED]"
|
||||
description="Enable ML ranking in quick fix for missing imports"/>
|
||||
|
||||
<registryKey key="disable.python.cache.update"
|
||||
defaultValue="false"
|
||||
restartRequired="false"
|
||||
description="Disables automatic updating of PyPI package cache and ranking on project startup."/>
|
||||
|
||||
<feedback.idleFeedbackSurvey implementation="com.jetbrains.python.statistics.feedback.PythonJobSurvey"/>
|
||||
<statistics.counterUsagesCollector implementationClass="com.jetbrains.python.statistics.feedback.PythonJobStatisticsCollector"/>
|
||||
<backgroundPostStartupActivity implementation="com.jetbrains.python.statistics.feedback.PythonFirstLaunchChecker"/>
|
||||
@@ -1020,4 +1025,5 @@ The Python plug-in provides smart editing for Python scripts. The feature set of
|
||||
<numericContainerPopupCustomizer implementation="com.jetbrains.python.debugger.pydev.tables.PyNumericContainerPopupCustomizerDefault"/>
|
||||
<pyDebugAsyncioCustomizer implementation="com.jetbrains.python.debugger.PyDebugAsyncioCustomizerDefault"/>
|
||||
</extensions>
|
||||
|
||||
</idea-plugin>
|
||||
|
||||
@@ -3,16 +3,11 @@ package com.jetbrains.python.packaging;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.startup.StartupActivity;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import com.jetbrains.python.sdk.PythonSdkUtil;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
@@ -29,9 +24,7 @@ final class PyPackagesUpdater implements StartupActivity, DumbAware {
|
||||
|
||||
@Override
|
||||
public void runActivity(@NotNull Project project) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
|
||||
if (!checkNeeded(project)) return;
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() || Registry.is("disable.python.cache.update") || !checkNeeded()) return;
|
||||
|
||||
try {
|
||||
PyPIPackageUtil.INSTANCE.updatePyPICache();
|
||||
@@ -41,18 +34,7 @@ final class PyPackagesUpdater implements StartupActivity, DumbAware {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasPython(Project project) {
|
||||
for (Module module : ModuleManager.getInstance(project).getModules()) {
|
||||
Sdk sdk = PythonSdkUtil.findPythonSdk(module);
|
||||
if (sdk != null && sdk.getSdkType() instanceof PythonSdkType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkNeeded(Project project) {
|
||||
if (!hasPython(project)) return false;
|
||||
private static boolean checkNeeded() {
|
||||
PyPackageService service = PyPackageService.getInstance();
|
||||
if (service.PYPI_REMOVED) return false;
|
||||
try {
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.startup.ProjectActivity
|
||||
import com.jetbrains.python.extensions.hasPython
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.jetbrains.python.packaging.PyPIPackageRanking
|
||||
import com.jetbrains.python.packaging.pip.PypiPackageCache
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -15,12 +15,11 @@ import kotlinx.coroutines.withContext
|
||||
class PythonPackagesUpdater : ProjectActivity {
|
||||
|
||||
override suspend fun execute(project: Project) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode || !project.hasPython) return
|
||||
if (ApplicationManager.getApplication().isUnitTestMode || Registry.`is`("disable.python.cache.update")) return
|
||||
withContext(Dispatchers.IO) {
|
||||
thisLogger().debug("Updating PyPI cache and ranking")
|
||||
service<PyPIPackageRanking>().reload()
|
||||
service<PypiPackageCache>().loadCache()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user