Ask questionsChange public API for execution to return an object and provide a callback which is called when interpreter setting changes

Old design:

Want to have a public API that returns an object which initially contains an array of strings for the command to execute a Python interpreter. The expectation is we may need to include environment variable details at some point. Update the API as follows,

export interface IExtensionApi {
     * Promise indicating whether all parts of the extension have completed loading or not.
     * @type {Promise<void>}
     * @memberof IExtensionApi
    ready: Promise<void>;
    debug: {
         * Generate an array of strings for commands to pass to the Python executable to launch the debugger for remote debugging.
         * Users can append another array of strings of what they want to execute along with relevant arguments to Python.
         * E.g `['/Users/..../pythonVSCode/pythonFiles/lib/python/debugpy', '--listen', 'localhost:57039', '--wait-for-client']`
         * @param {string} host
         * @param {number} port
         * @param {boolean} [waitUntilDebuggerAttaches=true]
         * @returns {Promise<string[]>}
        getRemoteLauncherCommand(host: string, port: number, waitUntilDebuggerAttaches: boolean): Promise<string[]>;

         * Gets the path to the debugger package used by the extension.
         * @returns {Promise<string>}
        getDebuggerPackagePath(): Promise<string | undefined>;
     * Return internal settings within the extension which are stored in VSCode storage
    settings: {
         * An event that is emitted when execution details (for a resource) change. For instance, when interpreter configuration changes.
        readonly onDidChangeExecutionDetails: Event<Uri | undefined>;
         * Returns all the details the consumer needs to execute code within the selected environment,
         * corresponding to the specified resource taking into account any workspace-specific settings
         * for the workspace to which this resource belongs.
         * @param {Resource} [resource] A resource for which the setting is asked for.
         * * When no resource is provided, the setting scoped to the first workspace folder is returned.
         * * If no folder is present, it returns the global setting.
         * @returns {({ execCommand: string[] | undefined })}
            resource?: Resource
        ): {
             * E.g of execution commands returned could be,
             * * `['<path to the interpreter set in settings>']`
             * * `['<path to the interpreter selected by the extension when setting is not set>']`
             * * `['conda', 'run', 'python']` which is used to run from within Conda environments.
             * or something similar for some other Python environments.
             * @type {(string[] | undefined)} When return value is `undefined`, it means no interpreter is set.
             * Otherwise, join the items returned using space to construct the full execution command.
            execCommand: string[] | undefined;
    datascience: {
         * Launches Data Viewer component.
         * @param {IDataViewerDataProvider} dataProvider Instance that will be used by the Data Viewer component to fetch data.
         * @param {string} title Data Viewer title
        showDataViewer(dataProvider: IDataViewerDataProvider, title: string): Promise<void>;

Answer questions karrtikr

@jakebailey We can send just pythonPath for now but as Brett pointed out, as the API begins to include more details, all of the execution details won't be readily available when firing the events. So we'll have to query these ourselves to send these along with events, which seems rather unnecessary as users can do that themselves if needed.


Related questions

Auto Scroll in the Jupyter output hot 3
Workspace contains pipfile but pipenv --venv failed hot 2
Can you turn off the Microsoft Python Language Server? hot 2
Unable to debug Python tests (duplicate entries in &#34;env&#34;) hot 2
Jupyter server crashed. Unable to connect. Cannot assign requested address hot 2
Auto Scroll in the Jupyter output hot 2
Unable to run launch targets with newest VS Code Python extension hot 2
Unable to start jupyter python interactive window hot 1
HBox output is not shown correctly in the interactive window hot 1
Debug -> Add Debug Configuration 'Cannot read property openConfigFile' hot 1
VSCode cannot connect to jupyter server; with browser this works fine hot 1
Linux arm64/aarch64 support hot 1
Add setting to disable icon for "Run Python File In Terminal" hot 1
Extension Host keeps crashing hot 1
Activate environment before debugging tests hot 1
Github User Rank List