Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode's Python environment discovery #340

Open
jfcherng opened this issue Jul 3, 2024 · 0 comments
Open

VSCode's Python environment discovery #340

jfcherng opened this issue Jul 3, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@jfcherng
Copy link
Collaborator

jfcherng commented Jul 3, 2024

Repository: https://github.com/microsoft/python-environment-tools

They introduced this in VSCode v1.91.0. That basically has the same purpose with https://github.com/sublimelsp/LSP-pyright/blob/master/plugin/venv_finder.py

It doesn't have Releases on Github but there are artifacts in the CI. E.g., https://github.com/microsoft/python-environment-tools/actions/runs/9775250841

But those CI artifacts will be no longer available within days. Here are re-uploaded backups...


Here's an output example of the pet tool:

$ pet --help

Usage: pet.exe [COMMAND]

Commands:
  find    Finds the environments and reports them to the standard output
  server  Starts the JSON RPC Server
  help    Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

$ pet find

It seems only to search Venv in the EXACTLY current directory. If I run the command in D:\Repo\LSP-bash\plugin, it won't find a Venv but only WindowsRegistry.

Environment (WindowsRegistry)
   Display-Name: Python 3.12 (64-bit)
   Executable  : C:\Users\jfcherng\AppData\Local\Programs\Python\Python312\python.exe
   Version     : 3.12.4
   Prefix      : C:\Users\jfcherng\AppData\Local\Programs\Python\Python312
   Architecture: x64
   Symlinks    : "C:\\Users\\jfcherng\\AppData\\Local\\Programs\\Python\\Python312\\python.exe"

Environment (Venv)
   Executable  : D:\Repo\LSP-bash\.venv\Scripts\python.exe
   Prefix      : D:\Repo\LSP-bash\.venv
   Symlinks    : "D:\\Repo\\LSP-bash\\.venv\\Scripts\\python.exe"


Breakdown by each locator:
--------------------------
Conda                : 13.1382ms
PipEnv               : 200ns
Poetry               : 979.8µs
PyEnv                : 478.7µs
Venv                 : 2.5µs
VirtualEnv           : 200ns
VirtualEnvWrapper    : 100ns
WindowsRegistry      : 3.2133ms
WindowsStore         : 115.8µs

Breakdown for finding Environments:
-----------------------------------
Using locators       : 16.4946ms
PATH Variable        : 85.6641ms
Global virtual envs  : 756.3µs
Custom search paths  : 9.0257ms

Environments (2):
------------------
Venv                 : 1
WindowsRegistry      : 1

Refresh completed in 88ms
@jfcherng jfcherng added documentation Improvements or additions to documentation enhancement New feature or request and removed documentation Improvements or additions to documentation labels Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant