Configuration ¶
Module: lean_interact.config
This module provides the LeanREPLConfig
class, which is used to configure the Lean REPL (Read-Eval-Print Loop) used
by the Lean servers in lean_interact.server
.
LeanREPLConfig ¶
LeanREPLConfig(
lean_version: str | None = None,
project: BaseProject | None = None,
repl_rev: str = DEFAULT_REPL_VERSION,
repl_git: str = DEFAULT_REPL_GIT_URL,
force_pull_repl: bool = False,
cache_dir: str | PathLike = DEFAULT_CACHE_DIR,
local_repl_path: str | PathLike | None = None,
build_repl: bool = True,
lake_path: str | PathLike = "lake",
memory_hard_limit_mb: int | None = None,
verbose: bool = False,
)
Initialize the Lean REPL configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lean_version
|
str | None
|
The Lean version you want to use. Should only be set when |
None
|
project
|
BaseProject | None
|
The project you want to use. Options:
- |
None
|
repl_rev
|
str
|
The REPL version / git revision you want to use. It is not recommended to change this value unless you know what you are doing.
It will first attempt to checkout |
DEFAULT_REPL_VERSION
|
repl_git
|
str
|
The git repository of the Lean REPL. It is not recommended to change this value unless you know what you are doing.
Note: Ignored when |
DEFAULT_REPL_GIT_URL
|
force_pull_repl
|
bool
|
If True, always pull the latest changes from the REPL git repository before checking out the revision.
By default, it is |
False
|
cache_dir
|
str | PathLike
|
The directory where the Lean REPL will be cached. Default is inside the package directory. |
DEFAULT_CACHE_DIR
|
local_repl_path
|
str | PathLike | None
|
A local path to the Lean REPL. This is useful if you want to use a local copy of the REPL. When provided, the REPL will not be downloaded from the git repository. This is particularly useful during REPL development. |
None
|
build_repl
|
bool
|
Whether to build the local REPL before running it. This option is ignored when |
True
|
lake_path
|
str | PathLike
|
The path to the lake executable. Default is "lake", which assumes it is in the system PATH. |
'lake'
|
memory_hard_limit_mb
|
int | None
|
The maximum memory usage in MB for the Lean server. Setting this value too low may lead to more command processing failures.
Only available on Linux platforms.
Default is |
None
|
verbose
|
bool
|
Whether to print additional information during the setup process. |
False
|
Examples:
# Basic configuration with default settings
config = LeanREPLConfig(verbose=True)
# Configuration with specific Lean version
config = LeanREPLConfig(lean_version="v4.19.0", verbose=True)
# Configuration with memory limits
config = LeanREPLConfig(memory_hard_limit_mb=2000)
# Configuration with custom REPL version and repository
config = LeanREPLConfig(
repl_rev="v4.21.0-rc3",
repl_git="https://github.com/leanprover-community/repl"
)
# Working with projects
config = LeanREPLConfig(
project=LocalProject(directory="/path/to/project"),
verbose=True
)
Source code in src/lean_interact/config.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|