Python package for Lean Environment Management
Project description
LeanUp
🎯 功能特性
- 📦 仓库管理: 安装和管理 Lean 仓库,支持交互式配置
- 🌍 跨平台支持: 支持 Linux、macOS 和 Windows
- 📦 简单易用: 通过
pip install leanup快速安装 - 🔄 命令代理: 透明代理所有 elan 命令,无缝体验
🚀 快速开始
安装
# 从 PyPI 安装
pip install leanup
# 或者克隆仓库后安装
git clone https://github.com/Lean-zh/LeanUp.git
cd LeanUp
pip install -e .
基础使用
# 查看帮助
leanup --help
# 安装 elan 并初始化配置
leanup init
# 安装
leanup install # stable
# 查看状态
leanup status
# 代理执行 elan 命令
leanup elan --help
leanup elan toolchain list
leanup elan toolchain install stable
leanup elan default stable
📖 详细使用指南
管理 Lean 工具链
安装 elan 后,您可以使用 leanup elan 命令来管理 Lean 工具链:
# 列出所有可用的工具链
leanup elan toolchain list
# 安装稳定版工具链
leanup elan toolchain install stable
# 安装夜间构建版本
leanup elan toolchain install leanprover/lean4:nightly
# 设置默认工具链
leanup elan default stable
# 更新所有工具链
leanup elan update
# 查看当前活动的工具链
leanup elan show
仓库管理
# 安装 Mathlib
leanup repo install leanprover-community/mathlib4
# 安装特定分支或标签
leanup repo install leanprover-community/mathlib4 -b v4.14.0
# 安装到自定义目录
leanup repo install Lean-zh/leanup -d /path/to/custom/dir
# 控制构建选项
leanup repo install leanprover-community/mathlib4 --lake-build
# 交互式
leanup repo install leanprover-community/mathlib4 -i
# 指定要构建的包
leanup repo install Lean-zh/repl --build-packages "REPL,REPL.Main"
# 列出已安装的仓库
leanup repo list
# 在指定目录中搜索仓库
leanup repo list --search-dir /path/to/repos
# 按名称过滤仓库
leanup repo list -n mathlib
交互式安装
使用 leanup repo install 的 --interactive 标志时,您可以配置:
- 仓库名称(必需)
- 仓库源的基础 URL
- 分支或标签
- 存储仓库的目标目录
- 自定义目标名称
- 是否在克隆后运行
lake update - 是否在克隆后运行
lake build - 要编译的特定构建包
- 是否覆盖现有目录
编程接口
使用 InstallConfig
from leanup.repo.manager import InstallConfig
# 创建安装配置
config = InstallConfig(
suffix="leanprover-community/mathlib4",
source="https://github.com",
branch="main",
dest_dir=Path("/path/to/repos"),
dest_name="mathlib4_main",
lake_update=True,
lake_build=True,
build_packages=["REPL", "REPL.Main"],
override=False
)
# 执行安装
config.install()
使用 RepoManager
from leanup.repo.manager import RepoManager
# 创建仓库管理器
repo = RepoManager("/path/to/directory")
# 克隆仓库
repo.clone_from("https://github.com/owner/repo.git", branch="main")
# 文件操作
repo.write_file("test.txt", "Hello world")
content = repo.read_file("test.txt")
repo.edit_file("test.txt", "world", "universe")
# 列出文件和目录
files = repo.list_files("*.lean")
dirs = repo.list_dirs()
使用 LeanRepo
from leanup.repo.manager import LeanRepo
# 创建 Lean 仓库管理器
lean_repo = LeanRepo("/path/to/lean/project")
# 获取项目信息
info = lean_repo.get_project_info()
print(f"Lean 版本: {info['lean_version']}")
print(f"有 lakefile: {info['has_lakefile_toml']}")
# Lake 操作
stdout, stderr, returncode = lean_repo.lake_init("my_project", "std")
stdout, stderr, returncode = lean_repo.lake_update()
stdout, stderr, returncode = lean_repo.lake_build()
stdout, stderr, returncode = lean_repo.lake_env_lean("Main.lean")
🛠️ 开发
环境设置
# 克隆仓库
git clone https://github.com/Lean-zh/LeanUp.git
cd LeanUp
# 安装开发依赖
pip install -e ".[dev]"
# 安装项目(可编辑模式)
pip install -e .
运行测试
# 运行所有测试
pytest tests/ -v
# 运行测试并生成覆盖率报告
coverage run -m pytest tests/
coverage report -m
⚙️ 配置
LeanUp 使用位于 ~/.leanup/config.toml 的配置文件。您可以自定义:
- 默认仓库源
- 仓库缓存目录
- elan 自动安装设置
- 仓库前缀和基础 URL
🌍 跨平台支持
LeanUp 在以下平台上经过测试:
- Linux: Ubuntu 20.04+, CentOS 7+, Debian 10+
- macOS: macOS 10.15+(Intel 和 Apple Silicon)
- Windows: Windows 10+
📊 项目状态
| 功能 | 状态 | 说明 |
|---|---|---|
| elan 安装 | ✅ | 支持自动检测平台和版本 |
| 命令代理 | ✅ | 透明传递所有 elan 命令 |
| 仓库管理 | ✅ | 安装和管理 Lean 仓库 |
| 交互式配置 | ✅ | 用户友好的设置过程 |
| 跨平台支持 | ✅ | Linux/macOS/Windows |
| 单元测试 | ✅ | 覆盖率 > 85% |
| CI/CD | ✅ | GitHub Actions 多平台测试 |
🤝 贡献
欢迎贡献代码!请查看 贡献指南 了解详细信息。
📝 许可证
本项目采用 MIT 许可证。详细信息请查看 LICENSE 文件。
🔗 相关链接
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
leanup-0.1.9.tar.gz
(24.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
leanup-0.1.9-py3-none-any.whl
(26.3 kB
view details)
File details
Details for the file leanup-0.1.9.tar.gz.
File metadata
- Download URL: leanup-0.1.9.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b12521b4154948d0d0478e8c35b2e9127acab2b12cecc97696115f0ddb3e49ef
|
|
| MD5 |
79be514817ad4318463fb3ab222c02d6
|
|
| BLAKE2b-256 |
fa68f7dd273ffcc448a07ab191259be18246b4b6cf1ce175b077ed87e72e36af
|
File details
Details for the file leanup-0.1.9-py3-none-any.whl.
File metadata
- Download URL: leanup-0.1.9-py3-none-any.whl
- Upload date:
- Size: 26.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f55a363bdc06a3d840c1485429247c7fa589228d38a5f74ada2b922935c8657
|
|
| MD5 |
93de31b250b8dabd53623281f16bfef2
|
|
| BLAKE2b-256 |
66b2ba0bbc6a27f3db714e277f1db24bdced4687a4b11cde37bb6a5a60ad5035
|