From 2410beaa8f2de4f6cfe4f57fbf99db573e908f13 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Fri, 6 Mar 2026 13:45:53 -0800 Subject: [PATCH 1/2] Revert "Get rid of vscode-engineering template in the npm publish pipeline (#1328)" This reverts commit b837aa15411d52c35934facda0448cd19ca6350e. --- build/azure-pipeline.npm.yml | 147 ++++++++------------------------- build/templates/pack-steps.yml | 7 ++ build/templates/test-steps.yml | 19 +++++ 3 files changed, 62 insertions(+), 111 deletions(-) create mode 100644 build/templates/pack-steps.yml create mode 100644 build/templates/test-steps.yml diff --git a/build/azure-pipeline.npm.yml b/build/azure-pipeline.npm.yml index 7d7efea5..53950365 100644 --- a/build/azure-pipeline.npm.yml +++ b/build/azure-pipeline.npm.yml @@ -5,124 +5,49 @@ pr: none resources: repositories: - - repository: MicroBuildTemplate - type: git - name: 1ESPipelineTemplates/MicroBuildTemplate - ref: refs/tags/release + - repository: templates + type: github + name: microsoft/vscode-engineering + ref: main + endpoint: Monaco parameters: - name: quality - displayName: 📦 Release Quality + displayName: Quality type: string - default: stable + default: latest values: - - stable - - preview - - - name: publishPackage - displayName: 🚀 Publish to npm + - latest + - next + - name: publishPythonEnvsApi + displayName: 🚀 Publish @vscode/python-environments type: boolean default: false - - name: buildSteps - type: stepList - default: - - task: NodeTool@0 - inputs: - versionSpec: '22.21.1' - displayName: Select Node version - - - script: npm ci - workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi - displayName: Install package dependencies - - - script: npm run compile - workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi - displayName: Compile TypeScript - - - script: npm pack --ignore-scripts - workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi - displayName: Pack npm package - -variables: - - name: TeamName - value: vscode-python-environments - - name: PackageName - value: '@vscode/python-environments' - - name: PackageDir - value: pythonEnvironmentsApi - - name: npmTag - ${{ if eq(parameters.quality, 'preview') }}: - value: next - ${{ else }}: - value: latest - extends: - template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate + template: azure-pipelines/npm-package/pipeline.yml@templates parameters: - sdl: - sourceAnalysisPool: VSEngSS-MicroBuild2022-1ES - codeSignValidation: - enabled: true - sbom: - enabled: true - pool: - name: AzurePipelines-EO - os: windows - - customBuildTags: - - ES365AIMigrationTooling - - stages: - - stage: Build - displayName: Build & Pack - jobs: - - job: BuildPackage - displayName: Build npm package - steps: - - ${{ each step in parameters.buildSteps }}: - - ${{ step }} - - - task: CopyFiles@2 - displayName: Copy package tarball to staging - inputs: - sourceFolder: $(Build.SourcesDirectory)/pythonEnvironmentsApi - contents: '*.tgz' - targetFolder: $(Build.ArtifactStagingDirectory) - - - task: 1ES.PublishBuildArtifacts@1 - displayName: Publish build artifact - inputs: - pathToPublish: $(Build.ArtifactStagingDirectory) - artifactName: npm-package - - - stage: Publish - displayName: Publish to npm - dependsOn: Build - condition: and(succeeded(), eq('${{ parameters.publishPackage }}', 'true')) - jobs: - - job: PublishPackage - displayName: Publish $(PackageName) - steps: - - task: DownloadBuildArtifacts@1 - displayName: Download build artifact - inputs: - buildType: current - downloadType: single - artifactName: npm-package - downloadPath: $(Build.ArtifactStagingDirectory) - - - task: NodeTool@0 - inputs: - versionSpec: '22.21.1' - displayName: Select Node version - - - bash: echo '//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}' > .npmrc - workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi - displayName: Configure npm auth - - - bash: npm publish $(Build.ArtifactStagingDirectory)/npm-package/*.tgz --tag $(npmTag) --access public - displayName: Publish to npm (${{ parameters.quality }}) - workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi - env: - NODE_AUTH_TOKEN: $(NpmAuthToken) + npmPackages: + - name: pythonEnvironmentsApi + testPlatforms: + - name: Linux + nodeVersions: + - 22.21.1 + - name: MacOS + nodeVersions: + - 22.21.1 + - name: Windows + nodeVersions: + - 22.21.1 + testSteps: + - template: /build/templates/test-steps.yml@self + parameters: + package: pythonEnvironmentsApi + buildSteps: + - template: /build/templates/pack-steps.yml@self + parameters: + package: pythonEnvironmentsApi + ghTagPrefix: release/pythonEnvironmentsApi/ + tag: ${{ parameters.quality }} + publishPackage: ${{ parameters.publishPythonEnvsApi }} + workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi diff --git a/build/templates/pack-steps.yml b/build/templates/pack-steps.yml new file mode 100644 index 00000000..b6492e5d --- /dev/null +++ b/build/templates/pack-steps.yml @@ -0,0 +1,7 @@ +parameters: +- name: package + +steps: + - script: npm install + workingDirectory: $(Build.SourcesDirectory)/${{ parameters.package }} + displayName: Install package dependencies diff --git a/build/templates/test-steps.yml b/build/templates/test-steps.yml new file mode 100644 index 00000000..2cba791f --- /dev/null +++ b/build/templates/test-steps.yml @@ -0,0 +1,19 @@ +parameters: +- name: package + type: string +- name: script + type: string + default: 'all:publish' + +steps: + - script: npm install + workingDirectory: $(Build.SourcesDirectory)/${{ parameters.package }} + displayName: Install package dependencies + - bash: | + /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + echo ">>> Started xvfb" + displayName: Start xvfb + condition: eq(variables['Agent.OS'], 'Linux') + - script: npm run ${{ parameters.script }} + workingDirectory: $(Build.SourcesDirectory)/${{ parameters.package }} + displayName: Verify package From 4df5314627d8752b3f1ab33528ecbfc1f403c802 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Fri, 6 Mar 2026 13:45:53 -0800 Subject: [PATCH 2/2] Revert "Add @vscode/python-environments npm package (#1317)" This reverts commit d7473274e821a13a0f5bfdbbaa6fd4ebeb77489c. --- .gitignore | 1 - build/azure-pipeline.npm.yml | 53 - build/templates/pack-steps.yml | 7 - build/templates/test-steps.yml | 19 - pythonEnvironmentsApi/.npmignore | 5 - pythonEnvironmentsApi/LICENSE.md | 21 - pythonEnvironmentsApi/README.md | 37 - pythonEnvironmentsApi/SECURITY.md | 41 - pythonEnvironmentsApi/package-lock.json | 42 - pythonEnvironmentsApi/package.json | 40 - pythonEnvironmentsApi/src/main.ts | 1298 ----------------------- pythonEnvironmentsApi/tsconfig.json | 15 - tsconfig.json | 2 +- 13 files changed, 1 insertion(+), 1580 deletions(-) delete mode 100644 build/azure-pipeline.npm.yml delete mode 100644 build/templates/pack-steps.yml delete mode 100644 build/templates/test-steps.yml delete mode 100644 pythonEnvironmentsApi/.npmignore delete mode 100644 pythonEnvironmentsApi/LICENSE.md delete mode 100644 pythonEnvironmentsApi/README.md delete mode 100644 pythonEnvironmentsApi/SECURITY.md delete mode 100644 pythonEnvironmentsApi/package-lock.json delete mode 100644 pythonEnvironmentsApi/package.json delete mode 100644 pythonEnvironmentsApi/src/main.ts delete mode 100644 pythonEnvironmentsApi/tsconfig.json diff --git a/.gitignore b/.gitignore index c9d40471..b5063653 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ dist node_modules .vscode-test/ *.vsix -*.tsbuildinfo .nox/ .venv/ **/__pycache__/ diff --git a/build/azure-pipeline.npm.yml b/build/azure-pipeline.npm.yml deleted file mode 100644 index 53950365..00000000 --- a/build/azure-pipeline.npm.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: $(Date:yyyyMMdd)$(Rev:.r) - -trigger: none -pr: none - -resources: - repositories: - - repository: templates - type: github - name: microsoft/vscode-engineering - ref: main - endpoint: Monaco - -parameters: - - name: quality - displayName: Quality - type: string - default: latest - values: - - latest - - next - - name: publishPythonEnvsApi - displayName: 🚀 Publish @vscode/python-environments - type: boolean - default: false - -extends: - template: azure-pipelines/npm-package/pipeline.yml@templates - parameters: - npmPackages: - - name: pythonEnvironmentsApi - testPlatforms: - - name: Linux - nodeVersions: - - 22.21.1 - - name: MacOS - nodeVersions: - - 22.21.1 - - name: Windows - nodeVersions: - - 22.21.1 - testSteps: - - template: /build/templates/test-steps.yml@self - parameters: - package: pythonEnvironmentsApi - buildSteps: - - template: /build/templates/pack-steps.yml@self - parameters: - package: pythonEnvironmentsApi - ghTagPrefix: release/pythonEnvironmentsApi/ - tag: ${{ parameters.quality }} - publishPackage: ${{ parameters.publishPythonEnvsApi }} - workingDirectory: $(Build.SourcesDirectory)/pythonEnvironmentsApi diff --git a/build/templates/pack-steps.yml b/build/templates/pack-steps.yml deleted file mode 100644 index b6492e5d..00000000 --- a/build/templates/pack-steps.yml +++ /dev/null @@ -1,7 +0,0 @@ -parameters: -- name: package - -steps: - - script: npm install - workingDirectory: $(Build.SourcesDirectory)/${{ parameters.package }} - displayName: Install package dependencies diff --git a/build/templates/test-steps.yml b/build/templates/test-steps.yml deleted file mode 100644 index 2cba791f..00000000 --- a/build/templates/test-steps.yml +++ /dev/null @@ -1,19 +0,0 @@ -parameters: -- name: package - type: string -- name: script - type: string - default: 'all:publish' - -steps: - - script: npm install - workingDirectory: $(Build.SourcesDirectory)/${{ parameters.package }} - displayName: Install package dependencies - - bash: | - /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - echo ">>> Started xvfb" - displayName: Start xvfb - condition: eq(variables['Agent.OS'], 'Linux') - - script: npm run ${{ parameters.script }} - workingDirectory: $(Build.SourcesDirectory)/${{ parameters.package }} - displayName: Verify package diff --git a/pythonEnvironmentsApi/.npmignore b/pythonEnvironmentsApi/.npmignore deleted file mode 100644 index 6b279cca..00000000 --- a/pythonEnvironmentsApi/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules/ -src/ -out/**/*.map -*.tsbuildinfo -tsconfig*.json diff --git a/pythonEnvironmentsApi/LICENSE.md b/pythonEnvironmentsApi/LICENSE.md deleted file mode 100644 index 767f4076..00000000 --- a/pythonEnvironmentsApi/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) Microsoft Corporation. All rights reserved. - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/pythonEnvironmentsApi/README.md b/pythonEnvironmentsApi/README.md deleted file mode 100644 index b7c96bac..00000000 --- a/pythonEnvironmentsApi/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# @vscode/python-environments - -This package provides type declarations and a helper to access the API exposed by the [Python Environments](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-python-envs) extension for VS Code. - -## Usage - -1. Install the package and add an `extensionDependencies` entry in your extension's `package.json`: - -```jsonc -// package.json -{ - "extensionDependencies": ["ms-python.vscode-python-envs"] -} -``` - -2. Install the npm package: - -``` -npm install @vscode/python-environments -``` - -3. Import and use the API in your extension: - -```typescript -import { PythonEnvironments } from '@vscode/python-environments'; - -export async function activate() { - const api = await PythonEnvironments.api(); - - // Get all discovered environments - const envs = await api.getEnvironments('all'); - for (const env of envs) { - console.log(env.displayName, env.version); - } -} -``` - diff --git a/pythonEnvironmentsApi/SECURITY.md b/pythonEnvironmentsApi/SECURITY.md deleted file mode 100644 index 1ceb287a..00000000 --- a/pythonEnvironmentsApi/SECURITY.md +++ /dev/null @@ -1,41 +0,0 @@ - - -## Security - -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). - -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's [Microsoft's definition of a security vulnerability]() of a security vulnerability, please report it to us as described below. - -## Reporting Security Issues - -**Please do not report security vulnerabilities through public GitHub issues.** - -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). - -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). - -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). - -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: - -- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) -- Full paths of source file(s) related to the manifestation of the issue -- The location of the affected source code (tag/branch/commit or direct URL) -- Any special configuration required to reproduce the issue -- Step-by-step instructions to reproduce the issue -- Proof-of-concept or exploit code (if possible) -- Impact of the issue, including how an attacker might exploit the issue - -This information will help us triage your report more quickly. - -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. - -## Preferred Languages - -We prefer all communications to be in English. - -## Policy - -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). - - diff --git a/pythonEnvironmentsApi/package-lock.json b/pythonEnvironmentsApi/package-lock.json deleted file mode 100644 index 3795b322..00000000 --- a/pythonEnvironmentsApi/package-lock.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "@vscode/python-environments", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "@vscode/python-environments", - "version": "1.0.0", - "license": "MIT", - "devDependencies": { - "@types/vscode": "^1.99.0", - "typescript": "^5.1.3" - }, - "engines": { - "node": ">=22.21.1", - "vscode": "^1.110.0" - } - }, - "node_modules/@types/vscode": { - "version": "1.109.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.109.0.tgz", - "integrity": "sha512-0Pf95rnwEIwDbmXGC08r0B4TQhAbsHQ5UyTIgVgoieDe4cOnf92usuR5dEczb6bTKEp7ziZH4TV1TRGPPCExtw==", - "dev": true, - "license": "MIT" - }, - "node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - } - } -} diff --git a/pythonEnvironmentsApi/package.json b/pythonEnvironmentsApi/package.json deleted file mode 100644 index bc4c5f74..00000000 --- a/pythonEnvironmentsApi/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "@vscode/python-environments", - "description": "An API facade for the Python Environments extension in VS Code", - "version": "1.0.0", - "author": { - "name": "Microsoft Corporation" - }, - "keywords": [ - "Python", - "VSCode", - "API", - "Environments" - ], - "main": "./out/main.js", - "types": "./out/main.d.ts", - "engines": { - "node": ">=22.21.1", - "vscode": "^1.110.0" - }, - "license": "MIT", - "homepage": "https://github.com/microsoft/vscode-python-environments/tree/main/pythonEnvironmentsApi", - "repository": { - "type": "git", - "url": "https://github.com/microsoft/vscode-python-environments" - }, - "bugs": { - "url": "https://github.com/microsoft/vscode-python-environments/issues" - }, - "scripts": { - "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node -e \"process.exitCode = 1\"", - "prepack": "npm run all:publish", - "all:publish": "git clean -xfd . && npm install && npm run compile", - "compile": "tsc -b ./tsconfig.json", - "clean": "node -e \"const fs = require('fs'); fs.rmSync('./out', { recursive: true, force: true });\"" - }, - "devDependencies": { - "@types/vscode": "^1.99.0", - "typescript": "^5.1.3" - } -} diff --git a/pythonEnvironmentsApi/src/main.ts b/pythonEnvironmentsApi/src/main.ts deleted file mode 100644 index c2290adf..00000000 --- a/pythonEnvironmentsApi/src/main.ts +++ /dev/null @@ -1,1298 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { - Disposable, - Event, - FileChangeType, - LogOutputChannel, - MarkdownString, - TaskExecution, - Terminal, - TerminalOptions, - ThemeIcon, - Uri, - extensions, -} from 'vscode'; - -/* - * Do not introduce any breaking changes to this API. - * This is the public API for other extensions to interact with the Python Environments extension. - */ - -/** - * The path to an icon, or a theme-specific configuration of icons. - */ -export type IconPath = - | Uri - | { - /** - * The icon path for the light theme. - */ - light: Uri; - /** - * The icon path for the dark theme. - */ - dark: Uri; - } - | ThemeIcon; - -/** - * Options for executing a Python executable. - */ -export interface PythonCommandRunConfiguration { - /** - * Path to the binary like `python.exe` or `python3` to execute. This should be an absolute path - * to an executable that can be spawned. - */ - executable: string; - - /** - * Arguments to pass to the python executable. These arguments will be passed on all execute calls. - * This is intended for cases where you might want to do interpreter specific flags. - */ - args?: string[]; -} - -/** - * Contains details on how to use a particular python environment - * - * Running In Terminal: - * 1. If {@link PythonEnvironmentExecutionInfo.activatedRun} is provided, then that will be used. - * 2. If {@link PythonEnvironmentExecutionInfo.activatedRun} is not provided, then: - * - If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is known, then that will be used. - * - If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is not known, then: - * - 'unknown' will be used if provided. - * - {@link PythonEnvironmentExecutionInfo.activation} will be used otherwise. - * - If {@link PythonEnvironmentExecutionInfo.shellActivation} is not provided, then {@link PythonEnvironmentExecutionInfo.activation} will be used. - * - If {@link PythonEnvironmentExecutionInfo.activation} is not provided, then {@link PythonEnvironmentExecutionInfo.run} will be used. - * - * Creating a Terminal: - * 1. If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is known, then that will be used. - * 2. If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is not known, then {@link PythonEnvironmentExecutionInfo.activation} will be used. - * 3. If {@link PythonEnvironmentExecutionInfo.shellActivation} is not provided, then: - * - 'unknown' will be used if provided. - * - {@link PythonEnvironmentExecutionInfo.activation} will be used otherwise. - * 4. If {@link PythonEnvironmentExecutionInfo.activation} is not provided, then {@link PythonEnvironmentExecutionInfo.run} will be used. - * - */ -export interface PythonEnvironmentExecutionInfo { - /** - * Details on how to run the python executable. - */ - run: PythonCommandRunConfiguration; - - /** - * Details on how to run the python executable after activating the environment. - * If set this will overrides the {@link PythonEnvironmentExecutionInfo.run} command. - */ - activatedRun?: PythonCommandRunConfiguration; - - /** - * Details on how to activate an environment. - */ - activation?: PythonCommandRunConfiguration[]; - - /** - * Details on how to activate an environment using a shell specific command. - * If set this will override the {@link PythonEnvironmentExecutionInfo.activation}. - * 'unknown' is used if shell type is not known. - * If 'unknown' is not provided and shell type is not known then - * {@link PythonEnvironmentExecutionInfo.activation} if set. - */ - shellActivation?: Map; - - /** - * Details on how to deactivate an environment. - */ - deactivation?: PythonCommandRunConfiguration[]; - - /** - * Details on how to deactivate an environment using a shell specific command. - * If set this will override the {@link PythonEnvironmentExecutionInfo.deactivation} property. - * 'unknown' is used if shell type is not known. - * If 'unknown' is not provided and shell type is not known then - * {@link PythonEnvironmentExecutionInfo.deactivation} if set. - */ - shellDeactivation?: Map; -} - -/** - * Interface representing the ID of a Python environment. - */ -export interface PythonEnvironmentId { - /** - * The unique identifier of the Python environment. - */ - id: string; - - /** - * The ID of the manager responsible for the Python environment. - */ - managerId: string; -} - -/** - * Display information for an environment group. - */ -export interface EnvironmentGroupInfo { - /** - * The name of the environment group. This is used as an identifier for the group. - * - * Note: The first instance of the group with the given name will be used in the UI. - */ - readonly name: string; - - /** - * The description of the environment group. - */ - readonly description?: string; - - /** - * The tooltip for the environment group, which can be a string or a Markdown string. - */ - readonly tooltip?: string | MarkdownString; - - /** - * The icon path for the environment group, which can be a string, Uri, or an object with light and dark theme paths. - */ - readonly iconPath?: IconPath; -} - -/** - * Interface representing information about a Python environment. - */ -export interface PythonEnvironmentInfo { - /** - * The name of the Python environment. - */ - readonly name: string; - - /** - * The display name of the Python environment. - */ - readonly displayName: string; - - /** - * The short display name of the Python environment. - */ - readonly shortDisplayName?: string; - - /** - * The display path of the Python environment. - */ - readonly displayPath: string; - - /** - * The version of the Python environment. - */ - readonly version: string; - - /** - * Path to the python binary or environment folder. - */ - readonly environmentPath: Uri; - - /** - * The description of the Python environment. - */ - readonly description?: string; - - /** - * The tooltip for the Python environment, which can be a string or a Markdown string. - */ - readonly tooltip?: string | MarkdownString; - - /** - * The icon path for the Python environment, which can be a string, Uri, or an object with light and dark theme paths. - */ - readonly iconPath?: IconPath; - - /** - * Information on how to execute the Python environment. This is required for executing Python code in the environment. - */ - readonly execInfo: PythonEnvironmentExecutionInfo; - - /** - * `sys.prefix` is the path to the base directory of the Python installation. Typically obtained by executing `sys.prefix` in the Python interpreter. - * This is required by extension like Jupyter, Pylance, and other extensions to provide better experience with python. - */ - readonly sysPrefix: string; - - /** - * Optional `group` for this environment. This is used to group environments in the Environment Manager UI. - */ - readonly group?: string | EnvironmentGroupInfo; - - /** - * Error message if the environment is broken or invalid. - * When set, indicates this environment has issues (e.g., broken symlinks, missing Python executable). - * The UI should display a warning indicator and show this message to help users diagnose and fix the issue. - */ - readonly error?: string; -} - -/** - * Interface representing a Python environment. - */ -export interface PythonEnvironment extends PythonEnvironmentInfo { - /** - * The ID of the Python environment. - */ - readonly envId: PythonEnvironmentId; -} - -/** - * Type representing the scope for setting a Python environment. - * Can be undefined or a URI. - */ -export type SetEnvironmentScope = undefined | Uri | Uri[]; - -/** - * Type representing the scope for getting a Python environment. - * Can be undefined or a URI. - */ -export type GetEnvironmentScope = undefined | Uri; - -/** - * Type representing the scope for creating a Python environment. - * Can be a Python project or 'global'. - */ -export type CreateEnvironmentScope = Uri | Uri[] | 'global'; -/** - * The scope for which environments are to be refreshed. - * - `undefined`: Search for environments globally and workspaces. - * - {@link Uri}: Environments in the workspace/folder or associated with the Uri. - */ -export type RefreshEnvironmentsScope = Uri | undefined; - -/** - * The scope for which environments are required. - * - `"all"`: All environments. - * - `"global"`: Python installations that are usually a base for creating virtual environments. - * - {@link Uri}: Environments for the workspace/folder/file pointed to by the Uri. - */ -export type GetEnvironmentsScope = Uri | 'all' | 'global'; - -/** - * Event arguments for when the current Python environment changes. - */ -export type DidChangeEnvironmentEventArgs = { - /** - * The URI of the environment that changed. - */ - readonly uri: Uri | undefined; - - /** - * The old Python environment before the change. - */ - readonly old: PythonEnvironment | undefined; - - /** - * The new Python environment after the change. - */ - readonly new: PythonEnvironment | undefined; -}; - -/** - * Enum representing the kinds of environment changes. - */ -export enum EnvironmentChangeKind { - /** - * Indicates that an environment was added. - */ - add = 'add', - - /** - * Indicates that an environment was removed. - */ - remove = 'remove', -} - -/** - * Event arguments for when the list of Python environments changes. - */ -export type DidChangeEnvironmentsEventArgs = { - /** - * The kind of change that occurred (add or remove). - */ - kind: EnvironmentChangeKind; - - /** - * The Python environment that was added or removed. - */ - environment: PythonEnvironment; -}[]; - -/** - * Type representing the context for resolving a Python environment. - */ -export type ResolveEnvironmentContext = Uri; - -export interface QuickCreateConfig { - /** - * The description of the quick create step. - */ - readonly description: string; - - /** - * The detail of the quick create step. - */ - readonly detail?: string; -} - -/** - * Interface representing an environment manager. - */ -export interface EnvironmentManager { - /** - * The name of the environment manager. Allowed characters (a-z, A-Z, 0-9, -, _). - */ - readonly name: string; - - /** - * The display name of the environment manager. - */ - readonly displayName?: string; - - /** - * The preferred package manager ID for the environment manager. This is a combination - * of publisher id, extension id, and {@link EnvironmentManager.name package manager name}. - * `.:` - * - * @example - * 'ms-python.python:pip' - */ - readonly preferredPackageManagerId: string; - - /** - * The description of the environment manager. - */ - readonly description?: string; - - /** - * The tooltip for the environment manager, which can be a string or a Markdown string. - */ - readonly tooltip?: string | MarkdownString | undefined; - - /** - * The icon path for the environment manager, which can be a string, Uri, or an object with light and dark theme paths. - */ - readonly iconPath?: IconPath; - - /** - * The log output channel for the environment manager. - */ - readonly log?: LogOutputChannel; - - /** - * The quick create details for the environment manager. Having this method also enables the quick create feature - * for the environment manager. Should Implement {@link EnvironmentManager.create} to support quick create. - */ - quickCreateConfig?(): QuickCreateConfig | undefined; - - /** - * Creates a new Python environment within the specified scope. Create should support adding a .gitignore file if it creates a folder within the workspace. If a manager does not support environment creation, do not implement this method; the UI disables "create" options when `this.manager.create === undefined`. - * @param scope - The scope within which to create the environment. - * @param options - Optional parameters for creating the Python environment. - * @returns A promise that resolves to the created Python environment, or undefined if creation failed. - */ - create?(scope: CreateEnvironmentScope, options?: CreateEnvironmentOptions): Promise; - - /** - * Removes the specified Python environment. - * @param environment - The Python environment to remove. - * @returns A promise that resolves when the environment is removed. - */ - remove?(environment: PythonEnvironment): Promise; - - /** - * Refreshes the list of Python environments within the specified scope. - * @param scope - The scope within which to refresh environments. - * @returns A promise that resolves when the refresh is complete. - */ - refresh(scope: RefreshEnvironmentsScope): Promise; - - /** - * Retrieves a list of Python environments within the specified scope. - * @param scope - The scope within which to retrieve environments. - * @returns A promise that resolves to an array of Python environments. - */ - getEnvironments(scope: GetEnvironmentsScope): Promise; - - /** - * Event that is fired when the list of Python environments changes. - */ - onDidChangeEnvironments?: Event; - - /** - * Sets the current Python environment within the specified scope. - * @param scope - The scope within which to set the environment. - * @param environment - The Python environment to set. If undefined, the environment is unset. - * @returns A promise that resolves when the environment is set. - */ - set(scope: SetEnvironmentScope, environment?: PythonEnvironment): Promise; - - /** - * Retrieves the current Python environment within the specified scope. - * @param scope - The scope within which to retrieve the environment. - * @returns A promise that resolves to the current Python environment, or undefined if none is set. - */ - get(scope: GetEnvironmentScope): Promise; - - /** - * Event that is fired when the current Python environment changes. - */ - onDidChangeEnvironment?: Event; - - /** - * Resolves the specified Python environment. The environment can be either a {@link PythonEnvironment} or a {@link Uri} context. - * - * This method is used to obtain a fully detailed {@link PythonEnvironment} object. The input can be: - * - A {@link PythonEnvironment} object, which might be missing key details such as {@link PythonEnvironment.execInfo}. - * - A {@link Uri} object, which typically represents either: - * - A folder that contains the Python environment. - * - The path to a Python executable. - * - * @param context - The context for resolving the environment, which can be a {@link PythonEnvironment} or a {@link Uri}. - * @returns A promise that resolves to the fully detailed {@link PythonEnvironment}, or `undefined` if the environment cannot be resolved. - */ - resolve(context: ResolveEnvironmentContext): Promise; - - /** - * Clears the environment manager's cache. - * - * @returns A promise that resolves when the cache is cleared. - */ - clearCache?(): Promise; -} - -/** - * Interface representing a package ID. - */ -export interface PackageId { - /** - * The ID of the package. - */ - id: string; - - /** - * The ID of the package manager. - */ - managerId: string; - - /** - * The ID of the environment in which the package is installed. - */ - environmentId: string; -} - -/** - * Interface representing package information. - */ -export interface PackageInfo { - /** - * The name of the package. - */ - readonly name: string; - - /** - * The display name of the package. - */ - readonly displayName: string; - - /** - * The version of the package. - */ - readonly version?: string; - - /** - * The description of the package. - */ - readonly description?: string; - - /** - * The tooltip for the package, which can be a string or a Markdown string. - */ - readonly tooltip?: string | MarkdownString | undefined; - - /** - * The icon path for the package, which can be a string, Uri, or an object with light and dark theme paths. - */ - readonly iconPath?: IconPath; - - /** - * The URIs associated with the package. - */ - readonly uris?: readonly Uri[]; -} - -/** - * Interface representing a package. - */ -export interface Package extends PackageInfo { - /** - * The ID of the package. - */ - readonly pkgId: PackageId; -} - -/** - * Enum representing the kinds of package changes. - */ -export enum PackageChangeKind { - /** - * Indicates that a package was added. - */ - add = 'add', - - /** - * Indicates that a package was removed. - */ - remove = 'remove', -} - -/** - * Event arguments for when packages change. - */ -export interface DidChangePackagesEventArgs { - /** - * The Python environment in which the packages changed. - */ - environment: PythonEnvironment; - - /** - * The package manager responsible for the changes. - */ - manager: PackageManager; - - /** - * The list of changes, each containing the kind of change and the package affected. - */ - changes: { kind: PackageChangeKind; pkg: Package }[]; -} - -/** - * Interface representing a package manager. - */ -export interface PackageManager { - /** - * The name of the package manager. Allowed characters (a-z, A-Z, 0-9, -, _). - */ - name: string; - - /** - * The display name of the package manager. - */ - displayName?: string; - - /** - * The description of the package manager. - */ - description?: string; - - /** - * The tooltip for the package manager, which can be a string or a Markdown string. - */ - tooltip?: string | MarkdownString | undefined; - - /** - * The icon path for the package manager, which can be a string, Uri, or an object with light and dark theme paths. - */ - iconPath?: IconPath; - - /** - * The log output channel for the package manager. - */ - log?: LogOutputChannel; - - /** - * Installs/Uninstall packages in the specified Python environment. - * @param environment - The Python environment in which to install packages. - * @param options - Options for managing packages. - * @returns A promise that resolves when the installation is complete. - */ - manage(environment: PythonEnvironment, options: PackageManagementOptions): Promise; - - /** - * Refreshes the package list for the specified Python environment. - * @param environment - The Python environment for which to refresh the package list. - * @returns A promise that resolves when the refresh is complete. - */ - refresh(environment: PythonEnvironment): Promise; - - /** - * Retrieves the list of packages for the specified Python environment. - * @param environment - The Python environment for which to retrieve packages. - * @returns An array of packages, or undefined if the packages could not be retrieved. - */ - getPackages(environment: PythonEnvironment): Promise; - - /** - * Event that is fired when packages change. - */ - onDidChangePackages?: Event; - - /** - * Clears the package manager's cache. - * @returns A promise that resolves when the cache is cleared. - */ - clearCache?(): Promise; -} - -/** - * Interface representing a Python project. - */ -export interface PythonProject { - /** - * The name of the Python project. - */ - readonly name: string; - - /** - * The URI of the Python project. - */ - readonly uri: Uri; - - /** - * The description of the Python project. - */ - readonly description?: string; - - /** - * The tooltip for the Python project, which can be a string or a Markdown string. - */ - readonly tooltip?: string | MarkdownString; -} - -/** - * Options for creating a Python project. - */ -export interface PythonProjectCreatorOptions { - /** - * The name of the Python project. - */ - name: string; - - /** - * Path provided as the root for the project. - */ - rootUri: Uri; - - /** - * Boolean indicating whether the project should be created without any user input. - */ - quickCreate?: boolean; -} - -/** - * Interface representing a creator for Python projects. - */ -export interface PythonProjectCreator { - /** - * The name of the Python project creator. - */ - readonly name: string; - - /** - * The display name of the Python project creator. - */ - readonly displayName?: string; - - /** - * The description of the Python project creator. - */ - readonly description?: string; - - /** - * The tooltip for the Python project creator, which can be a string or a Markdown string. - */ - readonly tooltip?: string | MarkdownString; - - /** - * Creates a new Python project(s) or, if files are not a project, returns Uri(s) to the created files. - * Anything that needs its own python environment constitutes a project. - * @param options Optional parameters for creating the Python project. - * @returns A promise that resolves to one of the following: - * - PythonProject or PythonProject[]: when a single or multiple projects are created. - * - Uri or Uri[]: when files are created that do not constitute a project. - * - undefined: if project creation fails. - */ - create(options?: PythonProjectCreatorOptions): Promise; - - /** - * A flag indicating whether the project creator supports quick create where no user input is required. - */ - readonly supportsQuickCreate?: boolean; -} - -/** - * Event arguments for when Python projects change. - */ -export interface DidChangePythonProjectsEventArgs { - /** - * The list of Python projects that were added. - */ - added: PythonProject[]; - - /** - * The list of Python projects that were removed. - */ - removed: PythonProject[]; -} - -export type PackageManagementOptions = - | { - /** - * Upgrade the packages if they are already installed. - */ - upgrade?: boolean; - - /** - * Show option to skip package installation or uninstallation. - */ - showSkipOption?: boolean; - /** - * The list of packages to install. - */ - install: string[]; - - /** - * The list of packages to uninstall. - */ - uninstall?: string[]; - } - | { - /** - * Upgrade the packages if they are already installed. - */ - upgrade?: boolean; - - /** - * Show option to skip package installation or uninstallation. - */ - showSkipOption?: boolean; - /** - * The list of packages to install. - */ - install?: string[]; - - /** - * The list of packages to uninstall. - */ - uninstall: string[]; - }; - -/** - * Options for creating a Python environment. - */ -export interface CreateEnvironmentOptions { - /** - * Provides some context about quick create based on user input. - * - if true, the environment should be created without any user input or prompts. - * - if false, the environment creation can show user input or prompts. - * This also means user explicitly skipped the quick create option. - * - if undefined, the environment creation can show user input or prompts. - * You can show quick create option to the user if you support it. - */ - quickCreate?: boolean; - /** - * Packages to install in addition to the automatically picked packages as a part of creating environment. - */ - additionalPackages?: string[]; -} - -/** - * Object representing the process started using run in background API. - */ -export interface PythonProcess { - /** - * The process ID of the Python process. - */ - readonly pid?: number; - - /** - * The standard input of the Python process. - */ - readonly stdin: NodeJS.WritableStream; - - /** - * The standard output of the Python process. - */ - readonly stdout: NodeJS.ReadableStream; - - /** - * The standard error of the Python process. - */ - readonly stderr: NodeJS.ReadableStream; - - /** - * Kills the Python process. - */ - kill(): void; - - /** - * Event that is fired when the Python process exits. - */ - onExit(listener: (code: number | null, signal: NodeJS.Signals | null) => void): void; -} - -export interface PythonEnvironmentManagerRegistrationApi { - /** - * Register an environment manager implementation. - * - * @param manager Environment Manager implementation to register. - * @returns A disposable that can be used to unregister the environment manager. - * @see {@link EnvironmentManager} - */ - registerEnvironmentManager(manager: EnvironmentManager): Disposable; -} - -export interface PythonEnvironmentItemApi { - /** - * Create a Python environment item from the provided environment info. This item is used to interact - * with the environment. - * - * @param info Some details about the environment like name, version, etc. needed to interact with the environment. - * @param manager The environment manager to associate with the environment. - * @returns The Python environment. - */ - createPythonEnvironmentItem(info: PythonEnvironmentInfo, manager: EnvironmentManager): PythonEnvironment; -} - -export interface PythonEnvironmentManagementApi { - /** - * Create a Python environment using environment manager associated with the scope. - * - * @param scope Where the environment is to be created. - * @param options Optional parameters for creating the Python environment. - * @returns The Python environment created. `undefined` if not created. - */ - createEnvironment( - scope: CreateEnvironmentScope, - options?: CreateEnvironmentOptions, - ): Promise; - - /** - * Remove a Python environment. - * - * @param environment The Python environment to remove. - * @returns A promise that resolves when the environment has been removed. - */ - removeEnvironment(environment: PythonEnvironment): Promise; -} - -export interface PythonEnvironmentsApi { - /** - * Initiates a refresh of Python environments within the specified scope. - * @param scope - The scope within which to search for environments. - * @returns A promise that resolves when the search is complete. - */ - refreshEnvironments(scope: RefreshEnvironmentsScope): Promise; - - /** - * Retrieves a list of Python environments within the specified scope. - * @param scope - The scope within which to retrieve environments. - * @returns A promise that resolves to an array of Python environments. - */ - getEnvironments(scope: GetEnvironmentsScope): Promise; - - /** - * Event that is fired when the list of Python environments changes. - * @see {@link DidChangeEnvironmentsEventArgs} - */ - onDidChangeEnvironments: Event; - - /** - * This method is used to get the details missing from a PythonEnvironment. Like - * {@link PythonEnvironment.execInfo} and other details. - * - * @param context : The PythonEnvironment or Uri for which details are required. - */ - resolveEnvironment(context: ResolveEnvironmentContext): Promise; -} - -export interface PythonProjectEnvironmentApi { - /** - * Sets the current Python environment within the specified scope. - * @param scope - The scope within which to set the environment. - * @param environment - The Python environment to set. If undefined, the environment is unset. - */ - setEnvironment(scope: SetEnvironmentScope, environment?: PythonEnvironment): Promise; - - /** - * Retrieves the current Python environment within the specified scope. - * @param scope - The scope within which to retrieve the environment. - * @returns A promise that resolves to the current Python environment, or undefined if none is set. - */ - getEnvironment(scope: GetEnvironmentScope): Promise; - - /** - * Event that is fired when the selected Python environment changes for Project, Folder or File. - * @see {@link DidChangeEnvironmentEventArgs} - */ - onDidChangeEnvironment: Event; -} - -export interface PythonEnvironmentManagerApi - extends - PythonEnvironmentManagerRegistrationApi, - PythonEnvironmentItemApi, - PythonEnvironmentManagementApi, - PythonEnvironmentsApi, - PythonProjectEnvironmentApi {} - -export interface PythonPackageManagerRegistrationApi { - /** - * Register a package manager implementation. - * - * @param manager Package Manager implementation to register. - * @returns A disposable that can be used to unregister the package manager. - * @see {@link PackageManager} - */ - registerPackageManager(manager: PackageManager): Disposable; -} - -export interface PythonPackageGetterApi { - /** - * Refresh the list of packages in a Python Environment. - * - * @param environment The Python Environment for which the list of packages is to be refreshed. - * @returns A promise that resolves when the list of packages has been refreshed. - */ - refreshPackages(environment: PythonEnvironment): Promise; - - /** - * Get the list of packages in a Python Environment. - * - * @param environment The Python Environment for which the list of packages is required. - * @returns The list of packages in the Python Environment. - */ - getPackages(environment: PythonEnvironment): Promise; - - /** - * Event raised when the list of packages in a Python Environment changes. - * @see {@link DidChangePackagesEventArgs} - */ - onDidChangePackages: Event; -} - -export interface PythonPackageItemApi { - /** - * Create a package item from the provided package info. - * - * @param info The package info. - * @param environment The Python Environment in which the package is installed. - * @param manager The package manager that installed the package. - * @returns The package item. - */ - createPackageItem(info: PackageInfo, environment: PythonEnvironment, manager: PackageManager): Package; -} - -export interface PythonPackageManagementApi { - /** - * Install/Uninstall packages into a Python Environment. - * - * @param environment The Python Environment into which packages are to be installed. - * @param packages The packages to install. - * @param options Options for installing packages. - */ - managePackages(environment: PythonEnvironment, options: PackageManagementOptions): Promise; -} - -export interface PythonPackageManagerApi - extends - PythonPackageManagerRegistrationApi, - PythonPackageGetterApi, - PythonPackageManagementApi, - PythonPackageItemApi {} - -export interface PythonProjectCreationApi { - /** - * Register a Python project creator. - * - * @param creator The project creator to register. - * @returns A disposable that can be used to unregister the project creator. - * @see {@link PythonProjectCreator} - */ - registerPythonProjectCreator(creator: PythonProjectCreator): Disposable; -} -export interface PythonProjectGetterApi { - /** - * Get all python projects. - */ - getPythonProjects(): readonly PythonProject[]; - - /** - * Get the python project for a given URI. - * - * @param uri The URI of the project - * @returns The project or `undefined` if not found. - */ - getPythonProject(uri: Uri): PythonProject | undefined; -} - -export interface PythonProjectModifyApi { - /** - * Add a python project or projects to the list of projects. - * - * @param projects The project or projects to add. - */ - addPythonProject(projects: PythonProject | PythonProject[]): void; - - /** - * Remove a python project from the list of projects. - * - * @param project The project to remove. - */ - removePythonProject(project: PythonProject): void; - - /** - * Event raised when python projects are added or removed. - * @see {@link DidChangePythonProjectsEventArgs} - */ - onDidChangePythonProjects: Event; -} - -/** - * The API for interacting with Python projects. A project in python is any folder or file that is a contained - * in some manner. For example, a PEP-723 compliant file can be treated as a project. A folder with a `pyproject.toml`, - * or just python files can be treated as a project. All this allows you to do is set a python environment for that project. - * - * By default all `vscode.workspace.workspaceFolders` are treated as projects. - */ -export interface PythonProjectApi extends PythonProjectCreationApi, PythonProjectGetterApi, PythonProjectModifyApi {} - -export interface PythonTerminalCreateOptions extends TerminalOptions { - /** - * Whether to disable activation on create. - */ - disableActivation?: boolean; -} - -export interface PythonTerminalCreateApi { - /** - * Creates a terminal and activates any (activatable) environment for the terminal. - * - * @param environment The Python environment to activate. - * @param options Options for creating the terminal. - * - * Note: Non-activatable environments have no effect on the terminal. - */ - createTerminal(environment: PythonEnvironment, options: PythonTerminalCreateOptions): Promise; -} - -/** - * Options for running a Python script or module in a terminal. - * - * Example: - * * Running Script: `python myscript.py --arg1` - * ```typescript - * { - * args: ["myscript.py", "--arg1"] - * } - * ``` - * * Running a module: `python -m my_module --arg1` - * ```typescript - * { - * args: ["-m", "my_module", "--arg1"] - * } - * ``` - */ -export interface PythonTerminalExecutionOptions { - /** - * Current working directory for the terminal. This in only used to create the terminal. - */ - cwd: string | Uri; - - /** - * Arguments to pass to the python executable. - */ - args?: string[]; - - /** - * Set `true` to show the terminal. - */ - show?: boolean; -} - -export interface PythonTerminalRunApi { - /** - * Runs a Python script or module in a terminal. This API will create a terminal if one is not available to use. - * If a terminal is available, it will be used to run the script or module. - * - * Note: - * - If you restart VS Code, this will create a new terminal, this is a limitation of VS Code. - * - If you close the terminal, this will create a new terminal. - * - In cases of multi-root/project scenario, it will create a separate terminal for each project. - */ - runInTerminal(environment: PythonEnvironment, options: PythonTerminalExecutionOptions): Promise; - - /** - * Runs a Python script or module in a dedicated terminal. This API will create a terminal if one is not available to use. - * If a terminal is available, it will be used to run the script or module. This terminal will be dedicated to the script, - * and selected based on the `terminalKey`. - * - * @param terminalKey A unique key to identify the terminal. For scripts you can use the Uri of the script file. - */ - runInDedicatedTerminal( - terminalKey: Uri | string, - environment: PythonEnvironment, - options: PythonTerminalExecutionOptions, - ): Promise; -} - -/** - * Options for running a Python task. - * - * Example: - * * Running Script: `python myscript.py --arg1` - * ```typescript - * { - * args: ["myscript.py", "--arg1"] - * } - * ``` - * * Running a module: `python -m my_module --arg1` - * ```typescript - * { - * args: ["-m", "my_module", "--arg1"] - * } - * ``` - */ -export interface PythonTaskExecutionOptions { - /** - * Name of the task to run. - */ - name: string; - - /** - * Arguments to pass to the python executable. - */ - args: string[]; - - /** - * The Python project to use for the task. - */ - project?: PythonProject; - - /** - * Current working directory for the task. Default is the project directory for the script being run. - */ - cwd?: string; - - /** - * Environment variables to set for the task. - */ - env?: { [key: string]: string }; -} - -export interface PythonTaskRunApi { - /** - * Run a Python script or module as a task. - * - */ - runAsTask(environment: PythonEnvironment, options: PythonTaskExecutionOptions): Promise; -} - -/** - * Options for running a Python script or module in the background. - */ -export interface PythonBackgroundRunOptions { - /** - * The Python environment to use for running the script or module. - */ - args: string[]; - - /** - * Current working directory for the script or module. Default is the project directory for the script being run. - */ - cwd?: string; - - /** - * Environment variables to set for the script or module. - */ - env?: { [key: string]: string | undefined }; -} -export interface PythonBackgroundRunApi { - /** - * Run a Python script or module in the background. This API will create a new process to run the script or module. - */ - runInBackground(environment: PythonEnvironment, options: PythonBackgroundRunOptions): Promise; -} - -export interface PythonExecutionApi - extends PythonTerminalCreateApi, PythonTerminalRunApi, PythonTaskRunApi, PythonBackgroundRunApi {} - -/** - * Event arguments for when the monitored `.env` files or any other sources change. - */ -export interface DidChangeEnvironmentVariablesEventArgs { - /** - * The URI of the file that changed. No `Uri` means a non-file source of environment variables changed. - */ - uri?: Uri; - - /** - * The type of change that occurred. - */ - changeType: FileChangeType; -} - -export interface PythonEnvironmentVariablesApi { - /** - * Get environment variables for a workspace. This picks up `.env` file from the root of the - * workspace. - * - * Order of overrides: - * 1. `baseEnvVar` if given or `process.env` - * 2. `.env` file from the "python.envFile" setting in the workspace. - * 3. `.env` file at the root of the python project. - * 4. `overrides` in the order provided. - * - * @param uri The URI of the project, workspace or a file in a for which environment variables are required.If not provided, - * it fetches the environment variables for the global scope. - * @param overrides Additional environment variables to override the defaults. - * @param baseEnvVar The base environment variables that should be used as a starting point. - */ - getEnvironmentVariables( - uri: Uri | undefined, - overrides?: ({ [key: string]: string | undefined } | Uri)[], - baseEnvVar?: { [key: string]: string | undefined }, - ): Promise<{ [key: string]: string | undefined }>; - - /** - * Event raised when `.env` file changes or any other monitored source of env variable changes. - */ - onDidChangeEnvironmentVariables: Event; -} - -/** - * The API for interacting with Python environments, package managers, and projects. - */ -export interface PythonEnvironmentApi - extends - PythonEnvironmentManagerApi, - PythonPackageManagerApi, - PythonProjectApi, - PythonExecutionApi, - PythonEnvironmentVariablesApi {} - -export const EXTENSION_ID = 'ms-python.vscode-python-envs'; - -// eslint-disable-next-line @typescript-eslint/no-namespace -export namespace PythonEnvironments { - /** - * Returns the API exposed by the Python Environments extension in VS Code. - */ - export async function api(): Promise { - const extension = extensions.getExtension(EXTENSION_ID); - if (extension === undefined) { - throw new Error(`Python Environments extension is not installed or is disabled`); - } - if (!extension.isActive) { - await extension.activate(); - } - const pythonEnvsApi: PythonEnvironmentApi = extension.exports; - return pythonEnvsApi; - } -} diff --git a/pythonEnvironmentsApi/tsconfig.json b/pythonEnvironmentsApi/tsconfig.json deleted file mode 100644 index f46bf161..00000000 --- a/pythonEnvironmentsApi/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "module": "commonjs", - "lib": ["ES2020"], - "declaration": true, - "strict": true, - "outDir": "./out", - "rootDir": "src", - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true - }, - "include": ["src"] -} diff --git a/tsconfig.json b/tsconfig.json index 9465f002..f33234f4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,5 +17,5 @@ "resolveJsonModule": true, "removeComments": true }, - "exclude": ["examples", "pythonEnvironmentsApi"] + "exclude": ["examples"] }