Skip to content
Draft
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
31 changes: 31 additions & 0 deletions api/package-lock.json

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

3 changes: 3 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@
"@types/node": "^22.0.0",
"@types/vscode": "^1.99.0",
"typescript": "^5.1.3"
},
"dependencies": {
"@renovatebot/pep440": "^3.1.0"
}
}
54 changes: 53 additions & 1 deletion api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
* This is the public API for other extensions to interact with the Python Environments extension.
*/

export type { Pep440Version } from '@renovatebot/pep440';
import type { Pep440Version } from '@renovatebot/pep440';
/**
* The path to an icon, or a theme-specific configuration of icons.
*/
Expand Down Expand Up @@ -691,6 +693,35 @@ export interface PackageManager {
* @returns A promise that resolves when the cache is cleared.
*/
clearCache?(): Promise<void>;

/**
* Returns the version of the underlying package management tool (e.g., pip, conda).
* @param environment - The Python environment context.
* @returns A promise that resolves to a SemVer object, or `undefined` if not available.
*/
getVersion?(environment: PythonEnvironment): Promise<Pep440Version | undefined>;

/**
* Retrieves the list of available versions for a given package.
* @param packageName - The name of the package to look up.
* @param environment - The Python environment context for the lookup.
* @returns A promise that resolves to an array of version strings (newest first),
Comment thread
edvilme marked this conversation as resolved.
* or `undefined` if this manager does not support version listing.
*/
getAvailableVersions?(packageName: string, environment: PythonEnvironment): Promise<Pep440Version[] | undefined>;

/**
* Formats a versioned install specification for this package manager.
*
* Different package managers use different syntax (e.g. pip uses `name==version`,
* conda uses `name=version`). Implement this method to return the correct format.
* When absent, callers should default to `name==version`.
*
* @param packageName - The name of the package.
* @param version - The version string.
* @returns The install specification string (e.g. `"requests==2.31.0"` or `"requests=2.31.0"`).
*/
formatInstallSpec?(packageName: string, version: string): string;
}

/**
Expand Down Expand Up @@ -1059,12 +1090,33 @@ export interface PythonPackageManagementApi {
managePackages(environment: PythonEnvironment, options: PackageManagementOptions): Promise<void>;
}

export interface Pep440VersionApi {
/**
* Get the version of the package manager tool associated with the given environment.
*
* @param environment The Python Environment whose package manager version is requested.
* @returns The SemVer version of the package manager tool, or `undefined` if not available.
*/
getPackageManagerVersion(environment: PythonEnvironment): Promise<Pep440Version | undefined>;

/**
* Get the list of available versions for a package from the package manager
* associated with the given environment.
*
* @param packageName The name of the package.
* @param environment The Python Environment context for the lookup.
* @returns An array of version strings (newest first), or `undefined` if not supported.
*/
getAvailableVersions(packageName: string, environment: PythonEnvironment): Promise<Pep440Version[] | undefined>;
}

export interface PythonPackageManagerApi
extends
PythonPackageManagerRegistrationApi,
PythonPackageGetterApi,
PythonPackageManagementApi,
PythonPackageItemApi {}
PythonPackageItemApi,
Pep440VersionApi {}

export interface PythonProjectCreationApi {
/**
Expand Down
64 changes: 56 additions & 8 deletions package-lock.json

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

Loading
Loading