-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve interpreter selection on different platforms #517
Conversation
await this.executeAndOutput('brew', ['install', 'python']); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if platform is Linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be like Windows then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think linux too has a version of Python pre-installed. @brettcannon Do you think we should support the system python in linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can leave Linux alone and let users figure it out?
return this._isMac; | ||
} | ||
public get isLinux(): boolean { | ||
return !(this.isWindows || this.isLinux); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the condition supposed to be return !(this.isWindows || this.isMac);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch...
src/test/index.ts
Outdated
@@ -13,7 +13,8 @@ const options: MochaSetupOptions & { retries: number } = { | |||
ui: 'tdd', | |||
useColors: true, | |||
timeout: 25000, | |||
retries: 3 | |||
retries: 3, | |||
grep: 'Signatures' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Booboo
src/client/extension.ts
Outdated
@@ -96,7 +97,7 @@ export async function activate(context: vscode.ExtensionContext) { | |||
const interpreterManager = new InterpreterManager(serviceContainer); | |||
|
|||
const pythonInstaller = new PythonInstaller(serviceContainer); | |||
const passed = await pythonInstaller.checkPythonInstallation(); | |||
const passed = await pythonInstaller.checkPythonInstallation(PythonSettings.getInstance()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought this might not be the best approach.
Users will now get bombarded with messages every time they open a python file in a new workspace.
Previously we'd display a warning on the bottom status bar. This change causes the display of a message every time you open a new workspace.
E.g. people using VS Code for scripting purposes or the like would now see this message every time, and we'd end up with the same issue we had with the linter. The solution was to add an option to stop showing the message ever again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion is to perform this check when installing a linter or something similar. I.e. at a point in time when the user has been presented with some UI (e.g. selecting an interperter, setting up tests, installing linter, etc from the extension)
src/test/index.ts
Outdated
@@ -14,7 +14,7 @@ const options: MochaSetupOptions & { retries: number } = { | |||
useColors: true, | |||
timeout: 25000, | |||
retries: 3, | |||
grep: 'Signatures' | |||
grep: 'Installation' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this.
if (this.platform.isMac) { | ||
if (await this.shell.showErrorMessage('Python that comes with Mac OS is not supported. Would you like to install regular Python now?', 'Yes', 'No') === 'Yes') { | ||
if (await this.shell.showErrorMessage('Python that comes with MacOS is not supported. Would you like to install regular Python now?', 'Yes', 'No') === 'Yes') { | ||
const brewInstalled = await this.ensureBrew(); | ||
if (!brewInstalled) { | ||
await this.shell.showErrorMessage('Unable to install Brew package manager'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about including instructions for the user to install Brew package manager
. E.g.
Unable to install Brew package manager, please install Brew package manager and try again
if (failed) { | ||
resolve(false); | ||
} | ||
if (isTestExecution()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to mock the process, without having to add conditional test
code. Feels a little dirty and I'm afraid we'd end up writing a lot more of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I tried that but mocking of events is pretty convoluted. Basically something needs to emit exit
asynchronously while test is running.
constructor( @inject(IServiceContainer) private platformService: IPlatformService) { } | ||
|
||
public get directorySeparatorChar(): string { | ||
return this.platformService.isWindows ? '\\' : '/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use path.sep
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
} | ||
|
||
public existsAsync(filePath: string): Promise<boolean> { | ||
return new Promise<boolean>(resolve => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use fs.pathExists
(use import * as fs from 'fs-extra'
).
As a suggestion, wouldn't it be better to have fileExists
and directoryExists
.
I have a need for this (have already create similar methods in another PR, where I want to differentiate between files and directories)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can add dir/file separately. We can add more as we go. I didn't want to add all possible combos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sure.
} | ||
|
||
public createDirectoryAsync(directoryPath: string): Promise<boolean> { | ||
return new Promise<boolean>(resolve => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use fs.mkdirp
. I wouldn't swallow the exceptions, just use return fs.mkdirp(directoryPath)
await this.executeAndOutput('brew', ['install', 'python']); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think linux too has a version of Python pre-installed. @brettcannon Do you think we should support the system python in linux?
src/client/extension.ts
Outdated
|
||
const persistentStateFactory = serviceManager.get<IPersistentStateFactory>(IPersistentStateFactory); | ||
const pythonSettings = settings.PythonSettings.getInstance(); | ||
sendStartupTelemetry(activated, serviceContainer); | ||
|
||
sortImports.activate(context, standardOutputChannel); | ||
const interpreterManager = new InterpreterManager(serviceContainer); | ||
|
||
const pythonInstaller = new PythonInstaller(serviceContainer); | ||
const passed = await pythonInstaller.checkPythonInstallation(PythonSettings.getInstance()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a good idea. Every time a Mac user opens a workspace or a python file in a new workspace, they have the potential of being hammered with a message. This could end up being an annoying message we had with the linters, the solution to which was to hide the message permanently.
Currently we display a warning in the status bar if the instance of python is invalid (none selected). Personally i prefer that (having learnt the lesson from the linter message). We could display a message when the user tries to install a linter, or setup unit tests or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say this is where @qubitron would have to get involved as this is sort of a UX thing and we've had problems in the past (annoying linter messages) which was conveyed in the survey.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Don't show this again
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd wait for @qubitron to comment on this.
src/test/index.ts
Outdated
@@ -13,7 +13,8 @@ const options: MochaSetupOptions & { retries: number } = { | |||
ui: 'tdd', | |||
useColors: true, | |||
timeout: 25000, | |||
retries: 3 | |||
retries: 3, | |||
grep: 'Installation' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove
Preliminary , working on tests