PY-80128: Update bundled venv because an old one is incompatible with the latest.

We use bundled venv to create virtual envs because system python might not have one. However, if it does, it must be compatible with the one we bundle. A new version was released 31.mar.2025. When installed, it breaks our bundled one.

So, we bundled a version. It doesn't work with Py2 though, dus we now check language level.


(cherry picked from commit cc7ff994bf32ef4333908321c6bb189a0e9ca9e5)

IJ-CR-159120

GitOrigin-RevId: 5b40ec5f1e8537ca3337013453c8e6e86b606589
This commit is contained in:
Ilya.Kazakevich
2025-04-01 21:59:13 +02:00
committed by intellij-monorepo-bot
parent 6df064a3dc
commit be033962fd
2 changed files with 9 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ import com.jetbrains.python.errorProcessing.PyError
import com.jetbrains.python.errorProcessing.failure
import com.jetbrains.python.sdk.PySdkSettings
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor
import com.jetbrains.python.validatePythonAndGetVersion
import com.jetbrains.python.venvReader.Directory
import com.jetbrains.python.venvReader.VirtualEnvReader
import kotlinx.coroutines.Dispatchers
@@ -42,7 +43,9 @@ suspend fun createVenv(
}
add(venvDir.pathString)
}
execService.execGetStdout(WhatToExec.Helper(python, helper = VIRTUALENV_ZIPAPP_NAME), args).getOr { return it }
val version = python.validatePythonAndGetVersion().getOr { return failure(it.error) }
val helper = if (version.isPy3K) VIRTUALENV_ZIPAPP_NAME else PY_2_VIRTUALENV_ZIPAPP_NAME
execService.execGetStdout(WhatToExec.Helper(python, helper = helper), args).getOr { return it }
val venvPython = withContext(Dispatchers.IO) {
@@ -58,6 +61,9 @@ suspend fun createVenv(
return Result.success(venvPython)
}
// venv helper
// venv helper, update from https://bootstrap.pypa.io/virtualenv.pyz
@Internal
const val VIRTUALENV_ZIPAPP_NAME: HelperName = "virtualenv-20.24.5.pyz"
const val VIRTUALENV_ZIPAPP_NAME: HelperName = "virtualenv-py3.pyz"
// Ancient version, the last one compatible with Py2
private const val PY_2_VIRTUALENV_ZIPAPP_NAME = "virtualenv-20.13.0.pyz"