Skip to content

Commit 6e8682c

Browse files
authored
Merge branch 'main' into notebook-path-fix
2 parents 9125191 + f34f14c commit 6e8682c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3658
-557
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.18.0

.vscode/launch.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"request": "launch",
1212
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
1313
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
14-
"preLaunchTask": "${defaultBuildTask}"
14+
"preLaunchTask": "npm: watch"
1515
},
1616
{
1717
"name": "Unit Tests",
@@ -30,7 +30,7 @@
3030
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
3131
"skipFiles": ["<node_internals>/**"],
3232
"outFiles": ["${workspaceFolder}/out/**/*.js", "!${workspaceFolder}/**/node_modules**/*"],
33-
"preLaunchTask": "tasks: watch-tests"
33+
"preLaunchTask": "npm: watch-tests"
3434
},
3535
{
3636
"name": "Extension Tests",
@@ -41,7 +41,7 @@
4141
"--extensionTestsPath=${workspaceFolder}/out/test/"
4242
],
4343
"outFiles": ["${workspaceFolder}/out/**/*.js", "${workspaceFolder}/dist/**/*.js"],
44-
"preLaunchTask": "tasks: watch-tests"
44+
"preLaunchTask": "${defaultBuildTask}"
4545
}
4646
]
4747
}

.vscode/settings.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
"typescript.tsc.autoDetect": "off",
1313
"editor.formatOnSave": true,
1414
"[typescript]": {
15-
"editor.defaultFormatter": "esbenp.prettier-vscode"
15+
"editor.defaultFormatter": "esbenp.prettier-vscode",
16+
"editor.codeActionsOnSave": {
17+
"source.organizeImports": "explicit"
18+
}
1619
},
1720
"[python]": {
1821
"editor.defaultFormatter": "charliermarsh.ruff",
19-
"diffEditor.ignoreTrimWhitespace": false
22+
"diffEditor.ignoreTrimWhitespace": false,
23+
"editor.codeActionsOnSave": {
24+
"source.organizeImports": "explicit"
25+
}
2026
},
2127
"prettier.tabWidth": 4,
2228
"python-envs.defaultEnvManager": "ms-python.python:venv",

.vscode/tasks.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@
2525
"presentation": {
2626
"reveal": "never",
2727
"group": "watchers"
28-
},
29-
"group": "build"
28+
}
3029
},
3130
{
32-
"label": "tasks: watch-tests",
31+
"label": "tasks: build",
3332
"dependsOn": ["npm: watch", "npm: watch-tests"],
34-
"problemMatcher": []
33+
"problemMatcher": [],
34+
"presentation": {
35+
"reveal": "never",
36+
"group": "watchers"
37+
}
3538
},
3639
{
3740
"type": "npm",

package.json

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@
8686
"onExP",
8787
"preview"
8888
]
89+
},
90+
"python-envs.terminal.autoActivationType": {
91+
"type": "string",
92+
"markdownDescription": "%python-envs.terminal.autoActivationType.description%",
93+
"default": "command",
94+
"enum": [
95+
"command",
96+
"shellStartup",
97+
"off"
98+
],
99+
"markdownEnumDescriptions": [
100+
"%python-envs.terminal.autoActivationType.command%",
101+
"%python-envs.terminal.autoActivationType.shellStartup%",
102+
"%python-envs.terminal.autoActivationType.off%"
103+
],
104+
"scope": "machine"
89105
}
90106
}
91107
},
@@ -228,6 +244,12 @@
228244
"title": "%python-envs.copyProjectPath.title%",
229245
"category": "Python Envs",
230246
"icon": "$(copy)"
247+
},
248+
{
249+
"command": "python-envs.terminal.revertStartupScriptChanges",
250+
"title": "%python-envs.terminal.revertStartupScriptChanges.title%",
251+
"category": "Python Envs",
252+
"icon": "$(discard)"
231253
}
232254
],
233255
"menus": {
@@ -487,7 +509,7 @@
487509
],
488510
"languageModelTools": [
489511
{
490-
"name": "python_environment_tool",
512+
"name": "python_environment",
491513
"displayName": "Get Python Environment Information",
492514
"modelDescription": "Provides details about the Python environment for a specified file or workspace, including environment type, Python version, run command, and installed packages with their versions.",
493515
"toolReferenceName": "pythonGetEnvironmentInfo",
@@ -508,7 +530,7 @@
508530
}
509531
},
510532
{
511-
"name": "python_install_package_tool",
533+
"name": "python_install_package",
512534
"displayName": "Install Python Package",
513535
"modelDescription": "Installs Python packages in the given workspace. Use this tool to install packages in the user's chosen environment.",
514536
"toolReferenceName": "pythonInstallPackage",
@@ -525,14 +547,14 @@
525547
},
526548
"description": "The list of packages to install."
527549
},
528-
"workspacePath": {
550+
"resourcePath": {
529551
"type": "string",
530-
"description": "Path to Python workspace that determines the environment for package installation."
552+
"description": "The path to the Python file or workspace to get the environment information for."
531553
}
532554
},
533555
"required": [
534556
"packageList",
535-
"workspacePath"
557+
"resourcePath"
536558
]
537559
}
538560
}

package.nls.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
"python-envs.pythonProjects.envManager.description": "The environment manager for creating and managing environments for this project.",
77
"python-envs.pythonProjects.packageManager.description": "The package manager for managing packages in environments for this project.",
88
"python-envs.terminal.showActivateButton.description": "Whether to show the 'Activate' button in the terminal menu",
9+
"python-envs.terminal.autoActivationType.description": "The type of activation to use when activating an environment in the terminal",
10+
"python-envs.terminal.autoActivationType.command": "Activation by executing a command in the terminal.",
11+
"python-envs.terminal.autoActivationType.shellStartup": "Activation by modifying the terminal shell startup script. To use this feature we will need to modify your shell startup scripts.",
12+
"python-envs.terminal.autoActivationType.off": "No automatic activation of environments.",
13+
"python-envs.terminal.revertStartupScriptChanges.title": "Revert Shell Startup Script Changes",
914
"python-envs.setEnvManager.title": "Set Environment Manager",
1015
"python-envs.setPkgManager.title": "Set Package Manager",
1116
"python-envs.addPythonProject.title": "Add Python Project",

src/api.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
// Licensed under the MIT License.
33

44
import {
5-
Uri,
65
Disposable,
7-
MarkdownString,
86
Event,
7+
FileChangeType,
98
LogOutputChannel,
10-
ThemeIcon,
11-
Terminal,
9+
MarkdownString,
1210
TaskExecution,
11+
Terminal,
1312
TerminalOptions,
14-
FileChangeType,
13+
ThemeIcon,
14+
Uri,
1515
} from 'vscode';
1616

1717
/**
@@ -333,7 +333,7 @@ export interface QuickCreateConfig {
333333
*/
334334
export interface EnvironmentManager {
335335
/**
336-
* The name of the environment manager.
336+
* The name of the environment manager. Allowed characters (a-z, A-Z, 0-9, -, _).
337337
*/
338338
readonly name: string;
339339

@@ -564,7 +564,7 @@ export interface DidChangePackagesEventArgs {
564564
*/
565565
export interface PackageManager {
566566
/**
567-
* The name of the package manager.
567+
* The name of the package manager. Allowed characters (a-z, A-Z, 0-9, -, _).
568568
*/
569569
name: string;
570570

@@ -667,9 +667,14 @@ export interface PythonProjectCreatorOptions {
667667
name: string;
668668

669669
/**
670-
* Optional path that may be provided as a root for the project.
670+
* Path provided as the root for the project.
671671
*/
672-
uri?: Uri;
672+
rootUri: Uri;
673+
674+
/**
675+
* Boolean indicating whether the project should be created without any user input.
676+
*/
677+
quickCreate?: boolean;
673678
}
674679

675680
/**
@@ -702,11 +707,20 @@ export interface PythonProjectCreator {
702707
readonly iconPath?: IconPath;
703708

704709
/**
705-
* Creates a new Python project or projects.
706-
* @param options - Optional parameters for creating the Python project.
707-
* @returns A promise that resolves to a Python project, an array of Python projects, or undefined.
710+
* Creates a new Python project(s) or, if files are not a project, returns Uri(s) to the created files.
711+
* Anything that needs its own python environment constitutes a project.
712+
* @param options Optional parameters for creating the Python project.
713+
* @returns A promise that resolves to one of the following:
714+
* - PythonProject or PythonProject[]: when a single or multiple projects are created.
715+
* - Uri or Uri[]: when files are created that do not constitute a project.
716+
* - undefined: if project creation fails.
717+
*/
718+
create(options?: PythonProjectCreatorOptions): Promise<PythonProject | PythonProject[] | Uri | Uri[] | undefined>;
719+
720+
/**
721+
* A flag indicating whether the project creator supports quick create where no user input is required.
708722
*/
709-
create(options?: PythonProjectCreatorOptions): Promise<PythonProject | PythonProject[] | undefined>;
723+
readonly supportsQuickCreate?: boolean;
710724
}
711725

712726
/**

src/common/command.api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { commands } from 'vscode';
3+
import { Disposable } from 'vscode-jsonrpc';
4+
5+
export function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable {
6+
return commands.registerCommand(command, callback, thisArg);
7+
}
38

49
export function executeCommand<T = unknown>(command: string, ...rest: any[]): Thenable<T> {
510
return commands.executeCommand(command, ...rest);

src/common/commands.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export namespace Commands {
2+
export const viewLogs = 'python-envs.viewLogs';
3+
}

src/common/errors/utils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as stackTrace from 'stack-trace';
2-
import { commands, LogOutputChannel, window } from 'vscode';
2+
import { commands, LogOutputChannel } from 'vscode';
33
import { Common } from '../localize';
4+
import { showErrorMessage, showWarningMessage } from '../window.apis';
45

56
export function parseStack(ex: Error) {
67
if (ex.stack && Array.isArray(ex.stack)) {
@@ -10,8 +11,8 @@ export function parseStack(ex: Error) {
1011
return stackTrace.parse.call(stackTrace, ex);
1112
}
1213

13-
export async function showErrorMessage(message: string, log?: LogOutputChannel) {
14-
const result = await window.showErrorMessage(message, Common.viewLogs);
14+
export async function showErrorMessageWithLogs(message: string, log?: LogOutputChannel) {
15+
const result = await showErrorMessage(message, Common.viewLogs);
1516
if (result === Common.viewLogs) {
1617
if (log) {
1718
log.show();
@@ -21,8 +22,8 @@ export async function showErrorMessage(message: string, log?: LogOutputChannel)
2122
}
2223
}
2324

24-
export async function showWarningMessage(message: string, log?: LogOutputChannel) {
25-
const result = await window.showWarningMessage(message, Common.viewLogs);
25+
export async function showWarningMessageWithLogs(message: string, log?: LogOutputChannel) {
26+
const result = await showWarningMessage(message, Common.viewLogs);
2627
if (result === Common.viewLogs) {
2728
if (log) {
2829
log.show();

0 commit comments

Comments
 (0)