@@ -18,11 +18,14 @@ import { IInterpreterService } from './interpreter/contracts';
1818import { IServiceContainer , IServiceManager } from './ioc/types' ;
1919import { JupyterExtensionIntegration } from './jupyter/jupyterIntegration' ;
2020import { traceError } from './logging' ;
21+ import { IDiscoveryAPI } from './pythonEnvironments/base/locator' ;
22+ import { buildEnvironmentApi } from './environmentApi' ;
2123
2224export function buildApi (
2325 ready : Promise < any > ,
2426 serviceManager : IServiceManager ,
2527 serviceContainer : IServiceContainer ,
28+ discoveryApi : IDiscoveryAPI ,
2629) : IExtensionApi {
2730 const configurationService = serviceContainer . get < IConfigurationService > ( IConfigurationService ) ;
2831 const interpreterService = serviceContainer . get < IInterpreterService > ( IInterpreterService ) ;
@@ -43,6 +46,42 @@ export function buildApi(
4346 start ( client : BaseLanguageClient ) : Promise < void > ;
4447 stop ( client : BaseLanguageClient ) : Promise < void > ;
4548 } ;
49+ } & {
50+ /**
51+ * @deprecated Use IExtensionApi.environments API instead.
52+ *
53+ * Return internal settings within the extension which are stored in VSCode storage
54+ */
55+ settings : {
56+ /**
57+ * An event that is emitted when execution details (for a resource) change. For instance, when interpreter configuration changes.
58+ */
59+ readonly onDidChangeExecutionDetails : Event < Uri | undefined > ;
60+ /**
61+ * Returns all the details the consumer needs to execute code within the selected environment,
62+ * corresponding to the specified resource taking into account any workspace-specific settings
63+ * for the workspace to which this resource belongs.
64+ * @param {Resource } [resource] A resource for which the setting is asked for.
65+ * * When no resource is provided, the setting scoped to the first workspace folder is returned.
66+ * * If no folder is present, it returns the global setting.
67+ * @returns {({ execCommand: string[] | undefined }) }
68+ */
69+ getExecutionDetails (
70+ resource ?: Resource ,
71+ ) : {
72+ /**
73+ * E.g of execution commands returned could be,
74+ * * `['<path to the interpreter set in settings>']`
75+ * * `['<path to the interpreter selected by the extension when setting is not set>']`
76+ * * `['conda', 'run', 'python']` which is used to run from within Conda environments.
77+ * or something similar for some other Python environments.
78+ *
79+ * @type {(string[] | undefined) } When return value is `undefined`, it means no interpreter is set.
80+ * Otherwise, join the items returned using space to construct the full execution command.
81+ */
82+ execCommand : string [ ] | undefined ;
83+ } ;
84+ } ;
4685 } = {
4786 // 'ready' will propagate the exception, but we must log it here first.
4887 ready : ready . catch ( ( ex ) => {
@@ -103,6 +142,7 @@ export function buildApi(
103142 start : ( client : BaseLanguageClient ) : Promise < void > => client . start ( ) ,
104143 stop : ( client : BaseLanguageClient ) : Promise < void > => client . stop ( ) ,
105144 } ,
145+ environments : buildEnvironmentApi ( discoveryApi , serviceContainer ) ,
106146 } ;
107147
108148 // In test environment return the DI Container.
0 commit comments