[python] Use virtualenv 20.13.0 for python <= 3.6 (PY-61694)

GitOrigin-RevId: 9b0ef4e9c50a5479510bba7d4b5ce7b9865d3e50
This commit is contained in:
lada.gagina
2023-09-22 14:48:52 +02:00
committed by intellij-monorepo-bot
parent 2654b58d90
commit ea722bc187
3 changed files with 18 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ public enum PythonHelper implements HelperPackage {
// Packaging tools
PACKAGING_TOOL("packaging_tool.py"),
VIRTUALENV_ZIPAPP("virtualenv-20.24.5.pyz"),
PY2_VIRTUALENV_ZIPAPP("virtualenv-20.13.0.pyz"),
LEGACY_VIRTUALENV_ZIPAPP("virtualenv-20.13.0.pyz"), // virtualenv used to create virtual environments for python 2.7 & 3.6
COVERAGEPY_OLD("coveragepy_old", ""),
COVERAGEPY_NEW("coveragepy_new", ""),

View File

@@ -37,7 +37,7 @@ import static com.jetbrains.python.sdk.PySdkExtKt.showSdkExecutionException;
@Deprecated
public class PyPackageManagerImpl extends PyPackageManagerImplBase {
private static final String VIRTUALENV_ZIPAPP_NAME = "virtualenv-20.24.5.pyz";
private static final String PY2_VIRTUALENV_ZIPAPP_NAME = "virtualenv-20.13.0.pyz";
private static final String LEGACY_VIRTUALENV_ZIPAPP_NAME = "virtualenv-20.13.0.pyz"; // virtualenv used to create virtual environments for python 2.7 & 3.6
private static final Logger LOG = Logger.getInstance(PyPackageManagerImpl.class);
@@ -189,7 +189,7 @@ public class PyPackageManagerImpl extends PyPackageManagerImplBase {
try {
getPythonProcessResult(
Objects.requireNonNull(getHelperPath(languageLevel.isPython2() ? PY2_VIRTUALENV_ZIPAPP_NAME : VIRTUALENV_ZIPAPP_NAME)),
Objects.requireNonNull(getHelperPath(isLegacyPython(languageLevel) ? LEGACY_VIRTUALENV_ZIPAPP_NAME : VIRTUALENV_ZIPAPP_NAME)),
args, false, true, null, List.of("-S"));
}
catch (ExecutionException e) {
@@ -202,6 +202,13 @@ public class PyPackageManagerImpl extends PyPackageManagerImplBase {
return (binary != null) ? binary : binaryFallback;
}
/**
* Is it a legacy python version that we still support
*/
private static @NotNull Boolean isLegacyPython(@NotNull LanguageLevel languageLevel) {
return languageLevel.isPython2() || languageLevel.isOlderThan(LanguageLevel.PYTHON37);
}
// public List<PyPackage> refreshAndGetPackagesIfNotInProgress(boolean alwaysRefresh) throws ExecutionException
private @NotNull String getHelperResult(@NotNull List<String> args,

View File

@@ -231,7 +231,7 @@ public class PyTargetEnvironmentPackageManager extends PyPackageManagerImplBase
TargetEnvironmentRequest targetEnvironmentRequest = helpersAwareTargetRequest.getTargetEnvironmentRequest();
PythonScriptExecution pythonExecution = PythonScripts.prepareHelperScriptExecution(
languageLevel.isPython2() ? PythonHelper.PY2_VIRTUALENV_ZIPAPP : PythonHelper.VIRTUALENV_ZIPAPP,
isLegacyPython(languageLevel) ? PythonHelper.LEGACY_VIRTUALENV_ZIPAPP : PythonHelper.VIRTUALENV_ZIPAPP,
helpersAwareTargetRequest);
if (useGlobalSite) {
pythonExecution.addParameter("--system-site-packages");
@@ -247,6 +247,13 @@ public class PyTargetEnvironmentPackageManager extends PyPackageManagerImplBase
return (binary != null) ? binary : binaryFallback;
}
/**
* Is it a legacy python version that we still support
*/
private static @NotNull Boolean isLegacyPython(@NotNull LanguageLevel languageLevel) {
return languageLevel.isPython2() || languageLevel.isOlderThan(LanguageLevel.PYTHON37);
}
@NotNull
private String getPythonProcessResult(@NotNull PythonExecution pythonExecution,
boolean askForSudo,