forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Create environment proposed API #21074
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
export interface ProposedExtensionAPI {} | ||
export interface ProposedExtensionAPI { | ||
karthiknadig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* Top level proposed APIs should go here. | ||
*/ | ||
} |
This file contains hidden or 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 hidden or 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
143 changes: 143 additions & 0 deletions
143
src/client/pythonEnvironments/creation/proposed.createEnvApis.ts
This file contains hidden or 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,143 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License | ||
|
||
import { Event, Disposable, WorkspaceFolder } from 'vscode'; | ||
import { EnvironmentTools } from '../../apiTypes'; | ||
|
||
export type CreateEnvironmentUserActions = 'Back' | 'Cancel'; | ||
export type EnvironmentProviderId = string; | ||
|
||
/** | ||
* Options used when creating a Python environment. | ||
*/ | ||
export interface CreateEnvironmentOptions { | ||
/** | ||
* Default `true`. If `true`, the environment creation handler is expected to install packages. | ||
*/ | ||
installPackages?: boolean; | ||
|
||
/** | ||
* Default `true`. If `true`, the environment creation provider is expected to add the environment to ignore list | ||
* for the source control. | ||
*/ | ||
ignoreSourceControl?: boolean; | ||
|
||
/** | ||
* Default `false`. If `true` the creation provider should show back button when showing QuickPick or QuickInput. | ||
*/ | ||
showBackButton?: boolean; | ||
karthiknadig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Default `true`. If `true`, the environment after creation will be selected. | ||
*/ | ||
selectEnvironment?: boolean; | ||
} | ||
|
||
/** | ||
* Params passed on `onWillCreateEnvironment` event handler. | ||
*/ | ||
export interface EnvironmentWillCreateEvent { | ||
/** | ||
* Options used to create a Python environment. | ||
*/ | ||
options: CreateEnvironmentOptions | undefined; | ||
} | ||
|
||
/** | ||
* Params passed on `onDidCreateEnvironment` event handler. | ||
*/ | ||
export interface EnvironmentDidCreateEvent extends CreateEnvironmentResult { | ||
/** | ||
* Options used to create the Python environment. | ||
*/ | ||
options: CreateEnvironmentOptions | undefined; | ||
} | ||
|
||
export interface CreateEnvironmentResult { | ||
/** | ||
* Workspace folder associated with the environment. | ||
*/ | ||
workspaceFolder: WorkspaceFolder | undefined; | ||
|
||
/** | ||
* Path to the executable python in the environment | ||
*/ | ||
path: string | undefined; | ||
|
||
/** | ||
* User action that resulted in exit from the create environment flow. | ||
*/ | ||
action: CreateEnvironmentUserActions | undefined; | ||
|
||
/** | ||
* Error if any occurred during environment creation. | ||
*/ | ||
error: Error | undefined; | ||
} | ||
|
||
/** | ||
* Extensions that want to contribute their own environment creation can do that by registering an object | ||
* that implements this interface. | ||
*/ | ||
export interface CreateEnvironmentProvider { | ||
/** | ||
* This API is called when user selects this provider from a QuickPick to select the type of environment | ||
* user wants. This API is expected to show a QuickPick or QuickInput to get the user input and return | ||
* the path to the Python executable in the environment. | ||
* | ||
* @param {CreateEnvironmentOptions} [options] Options used to create a Python environment. | ||
* | ||
* @returns a promise that resolves to the path to the | ||
* Python executable in the environment. Or any action taken by the user, such as back or cancel. | ||
*/ | ||
createEnvironment(options?: CreateEnvironmentOptions): Promise<CreateEnvironmentResult | undefined>; | ||
|
||
/** | ||
* Unique ID for the creation provider, typically <ExtensionId>:<environment-type | guid> | ||
*/ | ||
id: EnvironmentProviderId; | ||
|
||
/** | ||
* Display name for the creation provider. | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* Description displayed to the user in the QuickPick to select environment provider. | ||
*/ | ||
description: string; | ||
|
||
/** | ||
* Tools used to manage this environment. e.g., ['conda']. In the most to least priority order | ||
* for resolving and working with the environment. | ||
*/ | ||
tools: EnvironmentTools[]; | ||
} | ||
|
||
export interface ProposedCreateEnvironmentAPI { | ||
/** | ||
* This API can be used to detect when the environment creation starts for any registered | ||
* provider (including internal providers). This will also receive any options passed in | ||
* or defaults used to create environment. | ||
*/ | ||
onWillCreateEnvironment: Event<EnvironmentWillCreateEvent>; | ||
|
||
/** | ||
* This API can be used to detect when the environment provider exits for any registered | ||
* provider (including internal providers). This will also receive created environment path, | ||
* any errors, or user actions taken from the provider. | ||
*/ | ||
onDidCreateEnvironment: Event<EnvironmentDidCreateEvent>; | ||
|
||
/** | ||
* This API will show a QuickPick to select an environment provider from available list of | ||
* providers. Based on the selection the `createEnvironment` will be called on the provider. | ||
*/ | ||
createEnvironment(options?: CreateEnvironmentOptions): Promise<CreateEnvironmentResult | undefined>; | ||
|
||
/** | ||
* This API should be called to register an environment creation provider. It returns | ||
* a (@link Disposable} which can be used to remove the registration. | ||
*/ | ||
registerCreateEnvironmentProvider(provider: CreateEnvironmentProvider): Disposable; | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.