Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
python.interpreters.include
and python.interpreters.exclude
s…
…ettings (#6398) ### Summary - addresses #3574 for both the JS and native locators - also implements #6254 for the JS locator (previously [only implemented for the native locator](#6261)) - introduces new settings - `python.interpreters.include`: List of folders to search for Python installations. These folders are searched in addition to the default folders for your operating system. - `python.interpreters.exclude`: List of interpreter paths or folders to exclude from the available Python installations. These interpreters will not be displayed in the Positron UI. This option takes precedence over the `include` option. - adds new command available via Command Palette: `python.interpreters.debugInfo`: "Print interpreter debug information to Output" - Opens the Python Language Pack Output and prints python interpreter settings info as well as info about each discovered python runtime #### Settings UI <img width="1020" alt="image" src="https://github.com/user-attachments/assets/137d7798-50c8-4668-9444-db9917e91417" /> #### Settings JSON ```json "python.interpreters.include": [ "~/scratch" ], "python.interpreters.exclude": [ "/usr/bin/python3", "/opt/homebrew", "/usr/local/bin", "/opt/python", "~/scratch" ] ``` #### Python Language Pack Output Some log prefixes/messages to search for: - `pythonRuntimeDiscoverer`: to find out if any runtimes were filtered out during discovery - `shouldIncludeInterpreter`: whether or not the interpreter will be included based on the user settings - `Not registering runtime ${extraData.pythonPath} as it is excluded via user settings.`: if the runtime is not getting registered because the user excluded it - `getAdditionalEnvDirs`: native python finder -- list all the additional directories being searched, such as the user-included dirs <details><summary>Sample Output from `python.interpreters.debugInfo`: "Print interpreter debug information to Output"</summary> ```js 2025-02-24 10:43:17.026 [info] ===================================================================== 2025-02-24 10:43:17.026 [info] =============== [START] PYTHON INTERPRETER DEBUG INFO =============== 2025-02-24 10:43:17.026 [info] ===================================================================== 2025-02-24 10:43:17.026 [info] Python interpreter settings: { defaultInterpreterPath: '/Users/hello/qa-example-content/.venv/bin/python', 'interpreters.include': [ '/Users/hello/scratch' ], 'interpreters.exclude': [ '/usr/bin/python3', '/opt/homebrew', '/usr/local/bin', '/opt/python', '/Users/hello/scratch' ] } 2025-02-24 10:43:17.026 [info] Python interpreters discovered: [ { name: 'Python 3.13.1 64-bit', path: '/opt/homebrew/bin/python3', versionInfo: { version: '3.13.1', supportedVersion: true }, envInfo: { envType: 'Global', envName: '' }, enablementInfo: { visibleInUI: false, includedInSettings: false, excludedInSettings: true } }, { name: 'Python 3.10.4 64-bit', path: '/opt/python/3.10.4/bin/python', versionInfo: { version: '3.10.4', supportedVersion: true }, envInfo: { envType: 'Unknown', envName: '' }, enablementInfo: { visibleInUI: false, includedInSettings: false, excludedInSettings: true } }, { name: "Python 3.12.2 64-bit ('3.12.2': pyenv)", path: '/Users/hello/.pyenv/versions/3.12.2/bin/python', versionInfo: { version: '3.12.2', supportedVersion: true }, envInfo: { envType: 'Pyenv', envName: '3.12.2' }, enablementInfo: { visibleInUI: true, includedInSettings: false, excludedInSettings: false } }, { name: "Python 3.6.15 64-bit ('3.6.15': pyenv)", path: '/Users/hello/.pyenv/versions/3.6.15/bin/python', versionInfo: { version: '3.6.15', supportedVersion: false }, envInfo: { envType: 'Pyenv', envName: '3.6.15' }, enablementInfo: { visibleInUI: true, includedInSettings: false, excludedInSettings: false } }, { name: "Python 3.10.4 ('.venv': venv)", path: '/Users/hello/qa-example-content/.venv/bin/python', versionInfo: { version: '3.10.4', supportedVersion: true }, envInfo: { envType: 'Venv', envName: '.venv' }, enablementInfo: { visibleInUI: true, includedInSettings: false, excludedInSettings: false } }, { name: 'Python 3.10.4 64-bit (custom)', path: '/Users/hello/scratch/3.10.4/bin/python', versionInfo: { version: '3.10.4', supportedVersion: true }, envInfo: { envType: 'Unknown', envName: '' }, enablementInfo: { visibleInUI: false, includedInSettings: true, excludedInSettings: true } }, { name: 'Python 3.9.6 64-bit', path: '/usr/bin/python3', versionInfo: { version: '3.9.6', supportedVersion: true }, envInfo: { envType: 'Global', envName: '' }, enablementInfo: { visibleInUI: false, includedInSettings: false, excludedInSettings: true } }, { name: 'Python 3.10.4 64-bit', path: '/usr/local/bin/python3', versionInfo: { version: '3.10.4', supportedVersion: true }, envInfo: { envType: 'Global', envName: '' }, enablementInfo: { visibleInUI: false, includedInSettings: false, excludedInSettings: true } }, { name: 'Python 3.11.6 64-bit', path: '/usr/local/bin/python3.11', versionInfo: { version: '3.11.6', supportedVersion: true }, envInfo: { envType: 'Global', envName: '' }, enablementInfo: { visibleInUI: false, includedInSettings: false, excludedInSettings: true } } ] 2025-02-24 10:43:17.026 [info] ===================================================================== 2025-02-24 10:43:17.026 [info] ================ [END] PYTHON INTERPRETER DEBUG INFO ================ 2025-02-24 10:43:17.026 [info] ===================================================================== ``` </details> ### Release Notes #### New Features - New settings to include additional Python interpreter search directories or exclude Python interpreters from the UI (#3574) #### Bug Fixes - filters out unsupported (<3.8) Python versions from the `Python: Select Interpreter` dropdown (#3740) @isabelizimm ### QA Notes - Please verify these options using both the JS and Native locators. Toggle between the locators by updating setting `python.locator`. - Positron will need to be restarted upon changing the `python.interpreters.include`/`python.interpreters.exclude` settings so that discovery can re-run with the settings applied - If an interpreter path is captured in both options, it will be excluded - If a user has a python install they want to include at path `/1/2/3/4/5/3.10.4/bin/python`, they should use `/1/2/3/4/5` or `/1/2/3/4/5/3.10.4` as the included directory. - Windows users can specify paths with either path separator - Relative paths specified in the options are ignored - If a user starts an interpreter, then excludes or un-includes it and restarts Positron, it will still be selected upon restart - if they shut it down and then restart, it should no longer show --------- Co-authored-by: Isabel Zimmerman <54685329+isabelizimm@users.noreply.github.com>
- Loading branch information