forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve how to notify the user they don't have Python installed when …
…installing the Python extension for the first time (#19379) * Improve how to notify the user they don't have Python installed when installing the Python extension for the first time * Code reviews * Ensure create a python file automatically selects the language for the file as python * Hide tiles by default for Mac and Linux * Remove built-in new python file command
- Loading branch information
Kartik Raj
authored
Jul 5, 2022
1 parent
810588b
commit b15a1df
Showing
19 changed files
with
378 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 15 additions & 14 deletions
29
...ces/walkthrough/install-python-windows.md → ...s/walkthrough/install-python-windows-8.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
## Install Python on Windows | ||
|
||
If you don't have Python installed on your Windows machine, you can install it from the [Microsoft Store](https://aka.ms/AAd9rms). | ||
|
||
To verify it's installed, create a new terminal (<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>`</kbd>) and try running the following command: | ||
|
||
``` | ||
python --version | ||
``` | ||
|
||
You should see something similar to the following: | ||
``` | ||
Python 3.9.5 | ||
``` | ||
## Install Python on Windows | ||
|
||
If you don't have Python installed on your Windows machine, you can install it [from python.org](https://www.python.org/downloads). | ||
|
||
To verify it's installed, create a new terminal (<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>`</kbd>) and try running the following command: | ||
|
||
``` | ||
python --version | ||
``` | ||
|
||
You should see something similar to the following: | ||
``` | ||
Python 3.9.5 | ||
``` | ||
For additional information about using Python on Windows, see [Using Python on Windows at Python.org](https://docs.python.org/3.10/using/windows.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
src/client/common/application/commands/createFileCommand.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
export enum PythonWelcome { | ||
name = 'pythonWelcome', | ||
windowsInstallId = 'python.installPythonWin8', | ||
linuxInstallId = 'python.installPythonLinux', | ||
macOSInstallId = 'python.installPythonMac', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/client/interpreter/configuration/interpreterSelector/commands/installPython.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import { inject, injectable } from 'inversify'; | ||
import { IExtensionSingleActivationService } from '../../../../activation/types'; | ||
import { ExtensionContextKey } from '../../../../common/application/contextKeys'; | ||
import { ICommandManager, IContextKeyManager } from '../../../../common/application/types'; | ||
import { PythonWelcome } from '../../../../common/application/walkThroughs'; | ||
import { Commands, PVSC_EXTENSION_ID } from '../../../../common/constants'; | ||
import { IBrowserService, IDisposableRegistry } from '../../../../common/types'; | ||
import { IPlatformService } from '../../../../common/platform/types'; | ||
|
||
@injectable() | ||
export class InstallPythonCommand implements IExtensionSingleActivationService { | ||
public readonly supportedWorkspaceTypes = { untrustedWorkspace: false, virtualWorkspace: false }; | ||
|
||
constructor( | ||
@inject(ICommandManager) private readonly commandManager: ICommandManager, | ||
@inject(IContextKeyManager) private readonly contextManager: IContextKeyManager, | ||
@inject(IBrowserService) private readonly browserService: IBrowserService, | ||
@inject(IPlatformService) private readonly platformService: IPlatformService, | ||
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry, | ||
) {} | ||
|
||
public async activate(): Promise<void> { | ||
this.disposables.push(this.commandManager.registerCommand(Commands.InstallPython, () => this._installPython())); | ||
} | ||
|
||
public async _installPython(): Promise<void> { | ||
if (this.platformService.isWindows) { | ||
const version = await this.platformService.getVersion(); | ||
if (version.major > 8) { | ||
// OS is not Windows 8, ms-windows-store URIs are available: | ||
// https://docs.microsoft.com/en-us/windows/uwp/launch-resume/launch-store-app | ||
this.browserService.launch('ms-windows-store://pdp/?ProductId=9PJPW5LDXLZ5'); | ||
return; | ||
} | ||
} | ||
this.showInstallPythonTile(); | ||
} | ||
|
||
private showInstallPythonTile() { | ||
this.contextManager.setContext(ExtensionContextKey.showInstallPythonTile, true); | ||
let step: string; | ||
if (this.platformService.isWindows) { | ||
step = PythonWelcome.windowsInstallId; | ||
} else if (this.platformService.isLinux) { | ||
step = PythonWelcome.linuxInstallId; | ||
} else { | ||
step = PythonWelcome.macOSInstallId; | ||
} | ||
this.commandManager.executeCommand( | ||
'workbench.action.openWalkthrough', | ||
{ | ||
category: `${PVSC_EXTENSION_ID}#${PythonWelcome.name}`, | ||
step: `${PVSC_EXTENSION_ID}#${PythonWelcome.name}#${step}`, | ||
}, | ||
false, | ||
); | ||
} | ||
} |
Oops, something went wrong.