Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ All notable changes to the `@vscode/python-environments` API package are documen
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The published 1.0 package has top-level main and types; api/package.json now has only conditional exports. This accumulated unpublished change is not mentioned in the changelog.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preserve top-level main and types alongside exports, and test packed ESM and legacy CommonJS consumers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api file and types are generated inline by the pipelines (#1619). I can update the changelog to mention that as well


### Added

- Re-exported the `Pep440Version` type from `@renovatebot/pep440` for use with the new package version APIs.
- Added the optional `PackageInfo.isTransitive?: boolean` property to indicate whether a package is a transitive dependency.
- Added `GetPackagesOptions` with an optional `skipCache?: boolean` property. When `true`, package managers bypass cached data and query the underlying package management tool.
- Added optional `PackageManager.getPackageWatchTargets?(environment: PythonEnvironment): RelativePattern[]` to return manager-specific filesystem patterns to monitor for package installation and removal changes, in addition to the default site-packages metadata locations.
- Added optional `PackageManager.getDirectPackageNames?(environment: PythonEnvironment): Promise<Set<string> | undefined>` to return a best-effort set of direct, non-transitive package names when supported by the package manager.
- Added optional `PackageManager.getVersion?(environment: PythonEnvironment): Promise<Pep440Version | undefined>` to return the version of the underlying package management tool, such as pip, uv, or conda.
- Added optional `PackageManager.getPackageAvailableVersions?(environment: PythonEnvironment, packageName: string): Promise<Pep440Version[] | undefined>` to return the available versions of a package in newest-first order when supported.
- Added optional `PackageManager.formatInstallSpec?(packageName: string, version: string): string` to format a versioned install specification using manager-specific syntax, such as `name==version` for pip or `name=version` for conda.
- Added `PythonPackageGetterApi.getPackageAvailableVersions(environment: PythonEnvironment, packageName: string): Promise<Pep440Version[] | undefined>` so API consumers can query a package's available versions in newest-first order. Resolves to `undefined` when the environment's package manager does not support version listing.

### Changed

- Added the optional `options?: GetPackagesOptions` parameter to `PackageManager.getPackages(environment, options?)` and `PythonPackageGetterApi.getPackages(environment, options?)`. Consumers can set `options.skipCache` to request fresh package data.
- Changed `PackageManager.refresh(environment)` from `Promise<void>` to `Promise<Package[] | undefined>`, allowing implementations to return the refreshed package list.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a big change here- we would need to go to 2.0 if we want to change the return value of this method. Any other ways we could maybe do that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can look into having it return nothing for now, and then maybe discuss later on when reviewing the API

- Changed `PythonPackageGetterApi.refreshPackages(environment)` from `Promise<void>` to `Promise<Package[] | undefined>`, exposing the refreshed package list to API consumers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Non-blocking recommendation

Changing PackageManager.refresh from Promise<void> to Promise<Package[] | undefined> breaks external PackageManager implementations that return Promise<void>. Please confirm that external implementations are unsupported or document why this implementer-facing breaking change is appropriate for a minor release.


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would also want to packed-package contract tests before publishing

## [1.37.0]

- Aligned the API package version with the Python Environments extension version.
4 changes: 2 additions & 2 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@vscode/python-environments",
"description": "An API facade for the Python Environments extension in VS Code",
"version": "1.0.0",
"version": "1.1.0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Non-blocking recommendation

Please confirm the published npm version history before releasing 1.1.0. The changelog contains a 1.37.0 entry, so publishing 1.1.0 would be a downgrade if 1.37.0 was ever published; reconcile the changelog or select a version above the published latest.

"author": {
"name": "Microsoft Corporation"
},
Expand Down
16 changes: 16 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,22 @@ export interface PythonPackageGetterApi {
*/
getPackages(environment: PythonEnvironment, options?: GetPackagesOptions): Promise<Package[] | undefined>;

/**
* Get the list of available versions for a package, newest first.
*
* Support depends on the package manager backing the environment. Managers that do
* not implement version lookup resolve to `undefined`.
*
* @param environment The Python Environment context for the lookup.
* @param packageName The name of the package to look up.
* @returns A promise that resolves to an array of {@link Pep440Version} objects (newest first),
* or `undefined` if the package manager does not support version listing.
*/
getPackageAvailableVersions(
environment: PythonEnvironment,
packageName: string,
): Promise<Pep440Version[] | undefined>;

/**
* Event raised when the list of packages in a Python Environment changes.
* @see {@link DidChangePackagesEventArgs}
Expand Down
12 changes: 12 additions & 0 deletions src/features/pythonApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
PackageInfo,
PackageManagementOptions,
PackageManager,
Pep440Version,
PythonBackgroundRunOptions,
PythonEnvironment,
PythonEnvironmentApi,
Expand Down Expand Up @@ -319,6 +320,17 @@ export class PythonEnvironmentApiImpl implements PythonEnvironmentApi {
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Non-blocking recommendation

Please add coverage for both manager behaviors: returning available versions when supported and resolving undefined when the underlying manager omits the optional hook. The latter relies on the internal wrapper's guard and is the documented fallback contract for this new public method.

return manager.getPackages(context, options);
}
async getPackageAvailableVersions(
context: PythonEnvironment,
packageName: string,
): Promise<Pep440Version[] | undefined> {
await waitForEnvManagerId([context.envId.managerId]);
const manager = this.envManagers.getPackageManager(context);
if (!manager) {
return Promise.resolve(undefined);
}
return manager.getPackageAvailableVersions(context, packageName);
}
onDidChangePackages: Event<DidChangePackagesEventArgs> = this._onDidChangePackages.event;

createPackageItem(info: PackageInfo, environment: PythonEnvironment, manager: PackageManager): Package {
Expand Down
Loading