Python¶
lsp_utils.UvVenvManager
¶
UvVenvManager(plugin_storage_path: Path, pyproject_directory_resource_path: ResourcePath, server_binary_name: str)
Handles installation and update of dependencies specified in pyproject.toml.
Initialize UvVenvManager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_storage_path
|
Path
|
The path to the plugin's storage ( |
required |
pyproject_directory_resource_path
|
ResourcePath
|
The resource path to the directory that contains the
|
required |
server_binary_name
|
str
|
The name of the binary used to start the server within the venv's
|
required |
venv_path
property
¶
venv_path: Path
The path to the venv.
Depends on the contents of pyproject.toml and uv.lock and on the version of uv so changes when those are
updated.
venv_bin_path
property
¶
venv_bin_path: Path
The path to the directory with the binaries of the venv (Scripts on Windows, bin elsewhere).
on_pre_start_async
classmethod
¶
on_pre_start_async(context: OnPreStartContext, plugin_storage_path: Path, pyproject_directory_resource_path: ResourcePath, server_binary_name: str) -> None
Initialize UvVenvManager for an LspPlugin.
Automatically adds support for a root server_path package setting that defaults to "auto", meaning
that the package-managed server instance will be used. It can be overridden to use a custom server binary.
Also extends the PATH to include the venv directory if the managed server instance is used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
OnPreStartContext
|
The plugin context. |
required |
plugin_storage_path
|
Path
|
The path to the plugin's storage ( |
required |
pyproject_directory_resource_path
|
ResourcePath
|
The |
required |
server_binary_name
|
str
|
The name of the binary used to start the server within the venv's
|
required |
install_async
¶
Create the venv with the dependencies from pyproject.toml and uv.lock unless it already exists.
Blocks while installing so must be called on the async thread.
lsp_utils.UvRunner
¶
Runs uv commands through either system-local or self-managed instance of UV.
Installs self-managed version of uv in Package Storage if system-local version is not available. Make sure to initialize an instance on the async thread since it can perform long blocking operations when downloading uv.