Skip to content

Commit 0ec3e94

Browse files
authored
Allow package manager to fully control install/uninstall steps (#105)
Closes #99
1 parent 5992c4d commit 0ec3e94

File tree

17 files changed

+16264
-3663
lines changed

17 files changed

+16264
-3663
lines changed

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@
1818
"editor.defaultFormatter": "charliermarsh.ruff",
1919
"diffEditor.ignoreTrimWhitespace": false
2020
},
21-
"prettier.tabWidth": 4
21+
"prettier.tabWidth": 4,
22+
"python-envs.defaultEnvManager": "ms-python.python:venv",
23+
"python-envs.pythonProjects": []
2224
}

examples/sample1/src/api.ts

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,33 @@ export interface PythonEnvironmentId {
143143
managerId: string;
144144
}
145145

146+
/**
147+
* Display information for an environment group.
148+
*/
149+
export interface EnvironmentGroupInfo {
150+
/**
151+
* The name of the environment group. This is used as an identifier for the group.
152+
*
153+
* Note: The first instance of the group with the given name will be used in the UI.
154+
*/
155+
readonly name: string;
156+
157+
/**
158+
* The description of the environment group.
159+
*/
160+
readonly description?: string;
161+
162+
/**
163+
* The tooltip for the environment group, which can be a string or a Markdown string.
164+
*/
165+
readonly tooltip?: string | MarkdownString;
166+
167+
/**
168+
* The icon path for the environment group, which can be a string, Uri, or an object with light and dark theme paths.
169+
*/
170+
readonly iconPath?: IconPath;
171+
}
172+
146173
/**
147174
* Interface representing information about a Python environment.
148175
*/
@@ -202,6 +229,11 @@ export interface PythonEnvironmentInfo {
202229
* This is required by extension like Jupyter, Pylance, and other extensions to provide better experience with python.
203230
*/
204231
readonly sysPrefix: string;
232+
233+
/**
234+
* Optional `group` for this environment. This is used to group environments in the Environment Manager UI.
235+
*/
236+
readonly group?: string | EnvironmentGroupInfo;
205237
}
206238

207239
/**
@@ -218,7 +250,7 @@ export interface PythonEnvironment extends PythonEnvironmentInfo {
218250
* Type representing the scope for setting a Python environment.
219251
* Can be undefined or a URI.
220252
*/
221-
export type SetEnvironmentScope = undefined | Uri;
253+
export type SetEnvironmentScope = undefined | Uri | Uri[];
222254

223255
/**
224256
* Type representing the scope for getting a Python environment.
@@ -316,7 +348,9 @@ export interface EnvironmentManager {
316348
readonly displayName?: string;
317349

318350
/**
319-
* The preferred package manager ID for the environment manager.
351+
* The preferred package manager ID for the environment manager. This is a combination
352+
* of publisher id, extension id, and {@link EnvironmentManager.name package manager name}.
353+
* `<publisher-id>.<extension-id>:<package-manager-name>`
320354
*
321355
* @example
322356
* 'ms-python.python:pip'
@@ -563,15 +597,15 @@ export interface PackageManager {
563597
* @param packages - The packages to install.
564598
* @returns A promise that resolves when the installation is complete.
565599
*/
566-
install(environment: PythonEnvironment, packages: string[], options: PackageInstallOptions): Promise<void>;
600+
install(environment: PythonEnvironment, packages?: string[], options?: PackageInstallOptions): Promise<void>;
567601

568602
/**
569603
* Uninstalls packages from the specified Python environment.
570604
* @param environment - The Python environment from which to uninstall packages.
571605
* @param packages - The packages to uninstall, which can be an array of packages or strings.
572606
* @returns A promise that resolves when the uninstall is complete.
573607
*/
574-
uninstall(environment: PythonEnvironment, packages: Package[] | string[]): Promise<void>;
608+
uninstall(environment: PythonEnvironment, packages?: Package[] | string[]): Promise<void>;
575609

576610
/**
577611
* Refreshes the package list for the specified Python environment.
@@ -587,17 +621,6 @@ export interface PackageManager {
587621
*/
588622
getPackages(environment: PythonEnvironment): Promise<Package[] | undefined>;
589623

590-
/**
591-
* Get a list of installable items for a Python project.
592-
*
593-
* @param environment The Python environment for which to get installable items.
594-
*
595-
* Note: An environment can be used by multiple projects, so the installable items returned.
596-
* should be for the environment. If you want to do it for a particular project, then you should
597-
* ask user to select a project, and filter the installable items based on the project.
598-
*/
599-
getInstallable?(environment: PythonEnvironment): Promise<Installable[]>;
600-
601624
/**
602625
* Event that is fired when packages change.
603626
*/
@@ -717,45 +740,6 @@ export interface PackageInstallOptions {
717740
upgrade?: boolean;
718741
}
719742

720-
export interface Installable {
721-
/**
722-
* The display name of the package, requirements, pyproject.toml or any other project file.
723-
*/
724-
readonly displayName: string;
725-
726-
/**
727-
* Arguments passed to the package manager to install the package.
728-
*
729-
* @example
730-
* ['debugpy==1.8.7'] for `pip install debugpy==1.8.7`.
731-
* ['--pre', 'debugpy'] for `pip install --pre debugpy`.
732-
* ['-r', 'requirements.txt'] for `pip install -r requirements.txt`.
733-
*/
734-
readonly args: string[];
735-
736-
/**
737-
* Installable group name, this will be used to group installable items in the UI.
738-
*
739-
* @example
740-
* `Requirements` for any requirements file.
741-
* `Packages` for any package.
742-
*/
743-
readonly group?: string;
744-
745-
/**
746-
* Description about the installable item. This can also be path to the requirements,
747-
* version of the package, or any other project file path.
748-
*/
749-
readonly description?: string;
750-
751-
/**
752-
* External Uri to the package on pypi or docs.
753-
* @example
754-
* https://pypi.org/project/debugpy/ for `debugpy`.
755-
*/
756-
readonly uri?: Uri;
757-
}
758-
759743
export interface PythonProcess {
760744
/**
761745
* The process ID of the Python process.

0 commit comments

Comments
 (0)