-
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
Activate environment in terminal #614
Activate environment in terminal #614
Conversation
Archive of 0.7.0
* 'master' of https://github.com/Microsoft/vscode-python: Fixes #56 list all environments (#219) Fixes #57 Disable activation on debugging (#220) Fixes #26 Do not run linters when linters are disabled (#222)
* upstream/master: Fix typo in README.md (#252) Disable linter without workspaces (#241)
* upstream/master: Fix feedback service (#246) Fix django context initializer (#248) disable generation of tags file upon extension load (#264)
* upstream/master: Resolve pythonPath before comparing it to shebang (#273)
* upstream/master:
Fixes #22 to Detect anaconda from known locations (#221)
Use workspaceFolder token instead of workspaceRoot (#267)
Fix registry lookup response (#224)
Fix issues when running without debugging and debugged code terminates (#249)
* upstream/master: Fix debugging tests (#304)
* upstream/master: Remove jupyter functionality in favor of Jupyter extension (#302) Drop Python 2 URLs (#307)
* upstream/master: Remove setting python.formatting.formatOnSave in favor of the vs code setting (#312)
* upstream/master: Remove setting linting.lintOnTextChange as it was never implemented (#315)
* upstream/master: Fix travis build error (#326)
* upstream/master: add new npm deps with improved gulp for dev (#328)
* upstream/master: Update version of inversify package (#329)
* upstream/master: Document our dev process (#330)
* upstream/master: Document contribution to the code along with coding standards (#321)
* upstream/master: Add Simplified Chinese translation of commands (#240)
* upstream/master: Fix package.json (#347)
* upstream/master: #34, #110 - suppress Intellisense in strings and comments (#339) Re-factor code python execution framework (#345)
* upstream/master: Fix linters to make use of the new python code execution framework (#360) Update the versioning scheme (#356) Make npm happy in regards to line endings (#357)
* upstream/master: Ensure python path is not set if already set in user settings (#369) Use 'an' rather than 'a' before vowel words (#373)
* upstream/master: Use new environment variable parser (#362)
* upstream/master: update reflect metadata dependency (#604)
Codecov Report
@@ Coverage Diff @@
## master #614 +/- ##
=========================================
+ Coverage 58.06% 60.67% +2.6%
=========================================
Files 225 228 +3
Lines 10152 10125 -27
Branches 1751 1753 +2
=========================================
+ Hits 5895 6143 +248
+ Misses 4252 3977 -275
Partials 5 5
Continue to review full report at Codecov.
|
@brettcannon @MikhailArkhipov |
import { IFileSystem, IPlatformService } from './types'; | ||
|
||
@injectable() | ||
export class FileSystem implements IFileSystem { | ||
constructor( @inject(IServiceContainer) private platformService: IPlatformService) { } | ||
constructor( @inject(IPlatformService) private platformService: IPlatformService) { } |
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.
Up to you, there is always a discussion if one should pass container or just minimal service(s). However, if we are to switch to our own container implementation, it may not be injectable so we'll have to pass around container anyway.
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 agree, just didn't want to change existing code.
The plan going forward is to only pass the service container
} | ||
public async getActivationCommands(interpreter: PythonInterpreter, targetShell: TerminalShellType): Promise<string | string[] | undefined> { | ||
// Dependending on the target shell, look for the preferred script file. | ||
const scriptsInOrderOfPreference = targetShell === TerminalShellType.commandPrompt ? ['activate.bat', 'activate.ps1'] : ['activate.ps1', 'activate.bat']; |
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.
activate.cmd
?
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 couldn't find such a file in the python virtual environment 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.
OK. bat is usually old DOS thing, XP, win7 used to use cmd. Poweshell comes with Win10 preinstalled I think.
return; | ||
} | ||
|
||
const quotedScriptFile = scriptFile.indexOf(' ') > 0 ? `"${scriptFile}"` : scriptFile; |
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.
Looks like sequence used several times, perhaps move to findScriptFile
?
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.
Don't think thats right. The find shoudl only return the file, this is responsible for building the command for execution, and when a file has a space, then we need to quote it.
Can create a separate helper such as "quoteFilePath"
// import { IServiceContainer } from '../../../ioc/types'; | ||
// import { TerminalShellType } from '../types'; | ||
// import { BaseActivationCommandProvider } from './baseActivationProvider'; | ||
|
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.
tslint hates all-comments
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.
oop
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.
supposed to be removed.
const supportedProviders = providers.filter(provider => provider.isShellSupported(terminalShellType)); | ||
|
||
for (const provider of supportedProviders) { | ||
const activationCommands = await provider.getActivationCommands(interperterInfo, terminalShellType); |
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.
So we pick just the first one, right?
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.
return this.terminalServices.get(id)!; | ||
} | ||
private getTerminalId(resource?: Uri, title?: string): string { | ||
const terminalTitle = title ? title! : ''; |
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.
Bang probably not needed
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.
Perhaps something generic title, like '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.
Fixed.
src/client/common/terminal/types.ts
Outdated
|
||
export interface ITerminalActivationCommandProvider { | ||
isShellSupported(targetShell: TerminalShellType): boolean; | ||
getActivationCommands(interpreter: PythonInterpreter, targetShell: TerminalShellType): Promise<string | string[] | undefined>; |
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.
Might be simpler to have it always return an array, fewer cases to handle for the caller
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.
👍
Fixes #383