From bf697de1c363bb0d526937ee12bab13ae9c3ef49 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 14 Jul 2023 22:40:16 +0000 Subject: [PATCH 1/3] Update README for Python extension API to point to examples --- pythonExtensionApi/README.md | 24 ++++++++++++++++++++---- pythonExtensionApi/example/todo.txt | 0 2 files changed, 20 insertions(+), 4 deletions(-) delete mode 100644 pythonExtensionApi/example/todo.txt diff --git a/pythonExtensionApi/README.md b/pythonExtensionApi/README.md index d7ca4ccfdae4..eaae0105b9a7 100644 --- a/pythonExtensionApi/README.md +++ b/pythonExtensionApi/README.md @@ -4,8 +4,6 @@ This npm module implements an API facade for the Python extension in VS Code. ## Example -The source code of the example can be found [here](TODO Update example extension link here) - First we need to define a `package.json` for the extension that wants to use the API: ```jsonc @@ -24,8 +22,26 @@ First we need to define a `package.json` for the extension that wants to use the } ``` -TODO insert example here +The actual source code to get the active environment to run some script could look like this: ```typescript -TODO +// Load the Python extension API +const pythonApi: PythonExtension = await PythonExtension.api(); + +// This will return something like /usr/bin/python +const environmentPath = pythonApi.environments.getActiveEnvironmentPath(); + +// `environmentPath.path` carries the value of the setting. Note that this path may point to a folder and not the +// python binary. Depends entirely on how the env was created. +// E.g., `conda create -n myenv python` ensures the env has a python binary +// `conda create -n myenv` does not include a python binary. +// Also, the path specified may not be valid, use the following to get complete details for this environment if +// need be. + +const environment = await pythonApi.environments.resolveEnvironment(environmentPath); +if (environment) { + // run your script here. +} ``` + +Check out [the wiki](https://aka.ms/pythonEnvironmentApi) for many more examples and usage. diff --git a/pythonExtensionApi/example/todo.txt b/pythonExtensionApi/example/todo.txt deleted file mode 100644 index e69de29bb2d1..000000000000 From af2639caa1583a8f96d8a7e32f7539dd6de6e851 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 14 Jul 2023 22:48:15 +0000 Subject: [PATCH 2/3] Add import statement --- pythonExtensionApi/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pythonExtensionApi/README.md b/pythonExtensionApi/README.md index eaae0105b9a7..3f313721d17c 100644 --- a/pythonExtensionApi/README.md +++ b/pythonExtensionApi/README.md @@ -25,6 +25,9 @@ First we need to define a `package.json` for the extension that wants to use the The actual source code to get the active environment to run some script could look like this: ```typescript +// Import the API +import { PythonExtension } from '@vscode/python-extension'; + // Load the Python extension API const pythonApi: PythonExtension = await PythonExtension.api(); From bf6ad175112e37c8124ed154af94c5efc7ff3f0e Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 14 Jul 2023 22:50:59 +0000 Subject: [PATCH 3/3] Add trigger none --- build/azure-pipelines/pipeline.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/azure-pipelines/pipeline.yml b/build/azure-pipelines/pipeline.yml index 9cab7dedf9b1..85b41c16efc0 100644 --- a/build/azure-pipelines/pipeline.yml +++ b/build/azure-pipelines/pipeline.yml @@ -4,6 +4,8 @@ ############################################################################################### name: $(Date:yyyyMMdd)$(Rev:.r) +trigger: none + pr: none resources: