Skip to content

Commit 60db593

Browse files
authored
Show message in logs when distutils is missing. (#21125)
Fixes #21120
1 parent 9f24fbf commit 60db593

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

pythonFiles/create_venv.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,17 @@ def main(argv: Optional[Sequence[str]] = None) -> None:
161161
venv_installed = is_installed("venv")
162162
pip_installed = is_installed("pip")
163163
ensure_pip_installed = is_installed("ensurepip")
164+
distutils_installed = is_installed("distutils")
164165

165166
if not venv_installed:
166167
if sys.platform == "win32":
167168
raise VenvError("CREATE_VENV.VENV_NOT_FOUND")
168169
else:
169170
use_micro_venv = True
171+
if not distutils_installed:
172+
print("Install `python3-distutils` package or equivalent for your OS.")
173+
print("On Debian/Ubuntu: `sudo apt install python3-distutils`")
174+
raise VenvError("CREATE_VENV.DISTUTILS_NOT_INSTALLED")
170175

171176
if venv_exists(args.name):
172177
# A virtual environment with same name exists.

src/client/pythonEnvironments/creation/provider/venvProgressAndTelemetry.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const INSTALLING_PIP_MARKER = 'CREATE_VENV.INSTALLING_PIP';
2929
const INSTALL_PIP_FAILED_MARKER = 'CREATE_VENV.INSTALL_PIP_FAILED';
3030
const DOWNLOADING_PIP_MARKER = 'CREATE_VENV.DOWNLOADING_PIP';
3131
const DOWNLOAD_PIP_FAILED_MARKER = 'CREATE_VENV.DOWNLOAD_PIP_FAILED';
32+
const DISTUTILS_NOT_INSTALLED_MARKER = 'CREATE_VENV.DISTUTILS_NOT_INSTALLED';
3233

3334
export class VenvProgressAndTelemetry {
3435
private readonly processed = new Set<string>();
@@ -88,6 +89,16 @@ export class VenvProgressAndTelemetry {
8889
return PIP_NOT_INSTALLED_MARKER;
8990
},
9091
],
92+
[
93+
DISTUTILS_NOT_INSTALLED_MARKER,
94+
(_progress: CreateEnvironmentProgress) => {
95+
sendTelemetryEvent(EventName.ENVIRONMENT_FAILED, undefined, {
96+
environmentType: 'venv',
97+
reason: 'noDistUtils',
98+
});
99+
return VENV_NOT_INSTALLED_MARKER;
100+
},
101+
],
91102
[
92103
VENV_NOT_INSTALLED_MARKER,
93104
(_progress: CreateEnvironmentProgress) => {

src/client/telemetry/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ export interface IEventNamePropertyMapping {
20572057
*/
20582058
[EventName.ENVIRONMENT_FAILED]: {
20592059
environmentType: 'venv' | 'conda' | 'microvenv';
2060-
reason: 'noVenv' | 'noPip' | 'other';
2060+
reason: 'noVenv' | 'noPip' | 'noDistUtils' | 'other';
20612061
};
20622062
/**
20632063
* Telemetry event sent before installing packages.

0 commit comments

Comments
 (0)