Skip to content

Commit eed52de

Browse files
committed
Add commands to manage Python PATH
1 parent ef67c74 commit eed52de

File tree

4 files changed

+393
-1
lines changed

4 files changed

+393
-1
lines changed

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@
120120
"icon": "$(gear)",
121121
"when": "config.python.useEnvironmentsExtension != false"
122122
},
123+
{
124+
"command": "python-envs.addFolderToPythonPath",
125+
"title": "%python-envs.addFolderToPythonPath.title%",
126+
"category": "Python",
127+
"icon": "$(new-folder)",
128+
"when": "config.python.useEnvironmentsExtension != false"
129+
},
130+
{
131+
"command": "python-envs.openPythonPathFile",
132+
"title": "%python-envs.openPythonPathFile.title%",
133+
"category": "Python",
134+
"icon": "$(file-text)",
135+
"when": "config.python.useEnvironmentsExtension != false"
136+
},
123137
{
124138
"command": "python-envs.setPkgManager",
125139
"title": "%python-envs.setPkgManager.title%",
@@ -280,6 +294,10 @@
280294
],
281295
"menus": {
282296
"commandPalette": [
297+
{
298+
"command": "python-envs.addFolderToPythonPath",
299+
"when": "config.python.useEnvironmentsExtension != false"
300+
},
283301
{
284302
"command": "python-envs.refreshAllManagers",
285303
"when": "false"
@@ -405,6 +423,15 @@
405423
"command": "python-envs.refreshPackages",
406424
"when": "view == env-managers && viewItem =~ /.*pythonEnvironment.*/"
407425
},
426+
{
427+
"command": "python-envs.addFolderToPythonPath",
428+
"group": "inline",
429+
"when": "view == env-managers && viewItem =~ /.*pythonEnvironment.*/"
430+
},
431+
{
432+
"command": "python-envs.openPythonPathFile",
433+
"when": "view == env-managers && viewItem =~ /.*pythonEnvironment.*/"
434+
},
408435
{
409436
"command": "python-envs.packages",
410437
"group": "inline",
@@ -495,6 +522,11 @@
495522
"command": "python-envs.addPythonProjectGivenResource",
496523
"group": "inline",
497524
"when": "explorerViewletVisible && resourceExtname == .py"
525+
},
526+
{
527+
"command": "python-envs.addFolderToPythonPath",
528+
"group": "inline",
529+
"when": "explorerViewletVisible && explorerResourceIsFolder"
498530
}
499531
],
500532
"editor/title/run": [

package.nls.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"python-envs.terminal.revertStartupScriptChanges.title": "Revert Shell Startup Script Changes",
1515
"python-envs.reportIssue.title": "Report Issue",
1616
"python-envs.setEnvManager.title": "Set Environment Manager",
17+
"python-envs.addFolderToPythonPath.title": "Add Folder to Python PATH",
18+
"python-envs.addFolderToPythonPathForEnv.title": "Add Folder to Python PATH",
19+
"python-envs.openPythonPathFile.title": "Open Python PATH File",
1720
"python-envs.setPkgManager.title": "Set Package Manager",
1821
"python-envs.addPythonProject.title": "Add Python Project",
1922
"python-envs.addPythonProjectGivenResource.title": "Add as Python Project",

src/extension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ import {
4242
setEnvironmentCommand,
4343
setEnvManagerCommand,
4444
setPackageManagerCommand,
45+
addFolderToPythonPathCommand,
46+
openPythonPathFileCommand,
4547
} from './features/envCommands';
4648
import { PythonEnvironmentManagers } from './features/envManagers';
4749
import { EnvVarManager, PythonEnvVariableManager } from './features/execution/envVariableManager';
@@ -360,6 +362,12 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
360362
commands.registerCommand('python-envs.copyProjectPath', async (item) => {
361363
await copyPathToClipboard(item);
362364
}),
365+
commands.registerCommand('python-envs.addFolderToPythonPath', async (item) => {
366+
await addFolderToPythonPathCommand(item, envManagers);
367+
}),
368+
commands.registerCommand('python-envs.openPythonPathFile', async (item) => {
369+
await openPythonPathFileCommand(item, envManagers);
370+
}),
363371
commands.registerCommand('python-envs.revealProjectInExplorer', async (item) => {
364372
await revealProjectInExplorer(item);
365373
}),

0 commit comments

Comments
 (0)