forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding PYTHONSTARTUP with shell integration to environment variable c…
…ollection (microsoft#24111) Resolves: microsoft#23930 - setting to opt out of PYTHONSTARTUP injection. --------- Co-authored-by: Courtney Webster <[email protected]>
- Loading branch information
1 parent
07a0755
commit 3fcb3fa
Showing
14 changed files
with
91 additions
and
21 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { ExtensionContext, Uri } from 'vscode'; | ||
import * as path from 'path'; | ||
import { copy, createDirectory, getConfiguration } from '../common/vscodeApis/workspaceApis'; | ||
import { EXTENSION_ROOT_DIR } from '../constants'; | ||
|
||
export async function registerPythonStartup(context: ExtensionContext): Promise<void> { | ||
const config = getConfiguration('python'); | ||
const pythonrcSetting = config.get<boolean>('REPL.enableShellIntegration'); | ||
|
||
if (pythonrcSetting) { | ||
const storageUri = context.storageUri || context.globalStorageUri; | ||
try { | ||
await createDirectory(storageUri); | ||
} catch { | ||
// already exists, most likely | ||
} | ||
const destPath = Uri.joinPath(storageUri, 'pythonrc.py'); | ||
const sourcePath = path.join(EXTENSION_ROOT_DIR, 'python_files', 'pythonrc.py'); | ||
await copy(Uri.file(sourcePath), destPath, { overwrite: true }); | ||
context.environmentVariableCollection.replace('PYTHONSTARTUP', destPath.fsPath); | ||
} else { | ||
context.environmentVariableCollection.delete('PYTHONSTARTUP'); | ||
} | ||
} |
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
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