utils
Class info¶
🛈 DocStrings¶
Utility functions for dependency management.
check_requirements
¶
Check which requirements need to be installed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requirements
|
list[str]
|
List of requirements to check |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of requirements that are not yet installed |
Source code in src/llmling/depmanager/utils.py
collect_file_dependencies
¶
Collect dependencies from a Python file.
Source code in src/llmling/depmanager/utils.py
collect_file_dependencies_async
async
¶
Collect dependencies from a Python file asynchronously.
Source code in src/llmling/depmanager/utils.py
detect_uv
¶
Detect if we're running in a uv environment.
ensure_importable
¶
Ensure a module can be imported.
Source code in src/llmling/depmanager/utils.py
get_pip_command
¶
Get the appropriate pip command based on environment and settings.
Source code in src/llmling/depmanager/utils.py
get_venv_info
¶
Get information about the current virtual environment.
Source code in src/llmling/depmanager/utils.py
in_virtualenv
¶
Check if we're running inside a virtual environment or safe Jupyter kernel.
Returns:
| Type | Description |
|---|---|
bool
|
True if running in a venv, conda env, or Jupyter kernel within a venv |
Source code in src/llmling/depmanager/utils.py
install_requirements
¶
install_requirements(
requirements: list[str], *, pip_command: Command | None = None, pip_index_url: str | None = None
) -> set[str]
Install missing requirements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requirements
|
list[str]
|
Requirements to install |
required |
pip_command
|
Command | None
|
Base pip command to use (default: pip) |
None
|
pip_index_url
|
str | None
|
Optional custom PyPI index URL |
None
|
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of installed requirements |
Raises:
| Type | Description |
|---|---|
DependencyError
|
If installation fails |
Source code in src/llmling/depmanager/utils.py
scan_directory_deps
¶
Recursively scan directory for PEP 723 dependencies.
Source code in src/llmling/depmanager/utils.py
scan_directory_deps_async
async
¶
Recursively scan directory for PEP 723 dependencies asynchronously.
Source code in src/llmling/depmanager/utils.py
validate_script
¶
Verify script content is valid Python code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
The script content |
required |
script_path
|
str
|
Path to script (for error messages) |
required |
Raises:
| Type | Description |
|---|---|
DependencyError
|
If script content has invalid syntax |
Source code in src/llmling/depmanager/utils.py
verify_paths
¶
Verify that paths exist and are accessible.