Commit 556b74d7 authored by lada.gagina's avatar lada.gagina Committed by intellij-monorepo-bot
Browse files

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

GitOrigin-RevId: 88c6181ece24d1c36d2a27a8c7386ee8fbff2d08
parent a93fbdb1
Branches unavailable Tags unavailable
No related merge requests found
Showing with 18 additions and 4 deletions
+18 -4
......@@ -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", ""),
......
......@@ -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,
......
......@@ -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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment