Bitool
基于 Maturin 的 Rust + Python 混合架构工具集,将性能瓶颈和共性部分使用 Rust 实现,接口和逻辑部分使用 Python 实现。
特性
- 高性能:核心计算和 I/O 操作使用 Rust 实现(文件操作、文本处理、PDF 处理、加密等)
- 易用性:Python 提供简洁的 API 接口和 CLI 工具
- 可扩展:命令模式 + 技能注册表,支持功能扩展
- 跨平台:支持 Windows、Linux、macOS
- 双模式:CLI 和 GUI 双模式,满足不同使用场景
安装
pip install bitool
安装 GUI 应用需额外安装可选依赖:
pip install bitool[app]
应用一览
Bitool 内置 16 个独立应用,覆盖文件处理、文档工具、多媒体、LLM 等领域:
| 应用 | 命令 | 说明 | 模式 |
|---|---|---|---|
| 数字闹钟 | alarmclk |
桌面数字闹钟,支持贪睡延时 | GUI |
| Word 文档比较 | docdiff |
比较两个 Word 文档差异,生成修订版 | CLI |
| 文件扫描器 | filescanw |
多格式文件内容扫描(PDF/DOCX/XLSX/PPTX 等) | GUI |
| 图像转 ICO | img2ico / img2icow |
将图像转换为多尺寸 ICO 图标 | CLI/GUI |
| 图像转 PDF | img2pdfw |
将目录中的图像合并为单个 PDF | GUI |
| LLM 聊天客户端 | llmcliw |
本地大语言模型图形界面聊天客户端 | GUI |
| GGUF 模型量化 | llmqntw |
将 LLM 模型量化转换为 GGUF 格式 | GUI |
| LLM 推理服务器 | llmsvrw |
本地 LLM 模型推理 HTTP 服务 | GUI |
| LSC 曲线优化 | lscopt / lscoptw |
最小二乘曲线拟合优化工具 | CLI/GUI |
| PDF 加密解密 | pdfcrypt |
批量 PDF 加密/解密(128 位加密) | CLI |
| PDF 拆分 | pdfsplit |
按份数/页数/页码范围拆分 PDF | CLI |
| 通用答题系统 | quizbasew |
多题型答题系统,支持自适应学习 | GUI |
| 在线答题训练 | quiztrainer |
基于 Web 的答题训练平台(Flask) | Web |
| 视频格式转换 | videoconv / videoconvw |
基于 FFmpeg 的视频格式转换 | CLI/GUI |
| ZIP 加密 | zipenc |
批量加密为密码保护 ZIP(AES256) | CLI |
| RimWorld Mod 管理 | rimmodw |
RimWorld 游戏 Mod 启用/禁用/排序管理 | GUI |
Skills 工具集
Bitool 提供 20+ 个 CLI 技能工具,覆盖开发工作流的各个环节:
环境配置
| 命令 | 说明 |
|---|---|
envpy |
一键配置 pip/UV/Conda 国内镜像源(清华/阿里云) |
envrs |
一键配置 Rustup/Cargo 国内镜像源并安装 Rust |
构建与打包
| 命令 | 说明 |
|---|---|
pymake |
替代 Makefile 的构建工具,支持 Python+Rust 双包构建、测试、发布 |
pypack |
Python 项目完整打包工具(嵌入式 Python + 依赖 + 加载器) |
pyembedinstall |
下载安装嵌入式 Python |
pylibpack |
项目依赖库下载与打包 |
pysourcepack |
源代码打包 |
pyloadergen |
C 语言加载器生成与编译 |
pyarchive |
多格式归档(zip/tar/7z) |
版本与 Git
| 命令 | 说明 |
|---|---|
bumpversion |
语义化版本号自动递增(patch/minor/major),支持 Git 标签和提交 |
gitt |
Git 仓库常用操作封装(init/add/commit/push/pull/clean) |
包管理
| 命令 | 说明 |
|---|---|
pipt |
pip 操作封装,支持在线/离线模式和通配符卸载 |
文件处理
| 命令 | 说明 |
|---|---|
img2pdf |
多图片合并为 PDF(CLI 版) |
pdf2img |
PDF 逐页转换为图片 |
filedate |
移除文件日期前缀,替换为实际创建/修改时间 |
filelevel |
文件等级后缀重命名(公开/内部/机密/绝密) |
系统工具
| 命令 | 说明 |
|---|---|
which (wch) |
跨平台命令路径查找,支持模糊匹配 |
taskk |
跨平台进程查找与终止,支持模糊匹配 |
cls |
跨平台控制台清屏 |
sshcopyid |
SSH 公钥自动部署到远程服务器 |
开发
快速开始(推荐)
# 安装开发环境(自动构建 Rust + Python 双包)
pymake ia
# 验证安装
pymake t
常用命令
# 构建所有包(Rust + Python)
pymake ba
# 代码格式化与检查
pymake lint
# 运行测试
pymake t
# 清理所有构建产物
pymake ca
# 查看完整帮助
pymake help
手动构建(可选)
# 构建 Python 主包
cd .. && pip install -e .
项目结构
bitool/
├── src/
│ └── bitool/ # Python 主包(src layout)
│ ├── apps/ # 独立应用程序(16 个)
│ ├── cmd/ # 命令系统(命令模式)
│ ├── core/ # 核心基础设施
│ │ ├── config.py # JSON 配置管理
│ │ ├── database.py # 数据库连接池
│ │ ├── env.py # 环境变量管理
│ │ ├── logger.py # 日志系统
│ │ ├── registry.py # 注册表模式
│ │ ├── statemachine.py # 状态机
│ │ └── url.py # URL 工具
│ ├── gui/ # GUI 基础设施(PySide)
│ ├── skills/ # CLI 技能工具集(20+ 个)
│ ├── utils/ # 通用工具(执行器/文件/分析器)
│ ├── consts.py # 平台/架构常量
│ └── types.py # 通用类型定义
├── tests/ # 测试代码
├── pyproject.toml # Python 包配置
└── README.md
架构设计
Bitool 采用分层架构和 Rust+Python 混合设计:
┌─────────────────────────────────────────┐
│ Skills(技能层) │ 面向用户的 CLI 工具
│ BaseSkill / MapSkill │ 编排多个 Command
├─────────────────────────────────────────┤
│ Cmd(命令层) │ 原子操作单元
│ BaseCommand + 条件守卫 + 依赖管理 │ Command Pattern
├─────────────────────────────────────────┤
│ Core(核心层) │ 基础设施服务
│ 配置 / 数据库 / 日志 / 注册表 / 状态机 │
├─────────────────────────────────────────┤
│ Python Utils │ Rust Core (PyO3) │ 工具层
│ 执行器/文件 │ 文件/文本/PDF/加密/分析 │ 性能关键路径
└─────────────────────────────────────────┘
核心设计模式:
- 命令模式:
BaseCommand封装原子操作,支持条件守卫(allow/forbid)和依赖管理 - 模板方法模式:
BaseSkill.run()定义固定执行流程,子类通过add_arguments和create_scheduler定制行为 - 注册表模式:
Registry/SkillRegistry管理可扩展组件 - 混合架构:Rust 处理计算密集型任务(文件 I/O、文本处理、PDF、加密),Python 负责编排和用户交互
Python API 示例
from bitool import CommandScheduler, Constants, profile
# 获取平台信息
print(Constants.is_windows) # True/False
print(Constants.arch) # 'amd64' / 'arm64'
# 使用性能分析装饰器
@profile
def heavy_task(): ...
# 使用命令调度器编排操作
from bitool.scheduler import CommandScheduler, ReadFileCommand, WriteFileCommand, MergePdfsCommand, RunCommand
scheduler = CommandScheduler()
scheduler.add(ReadFileCommand(path="input.txt"))
scheduler.add(RunCommand(cmd="python process.py"))
scheduler.run()
Rust 核心 API
import bitool_core
# 文本处理
processor = bitool_core.PyTextProcessor()
result = processor.regex_search(pattern, text)
# PDF 操作
pdf_ops = bitool_core.PyPdfOps()
pdf_ops.merge_pdfs(["a.pdf", "b.pdf"], "merged.pdf")
# 性能分析
profiler = bitool_core.PyPerformanceProfiler()
profiler.start("task_name")
# ... 执行任务 ...
record = profiler.stop("task_name")
print(record.elapsed_ms)
许可证
MIT License
Metadata
Release files for bitool 0.1.20
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bitool-0.1.20.tar.gz | 1.4 MB | Without provenance | Details for bitool-0.1.20.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bitool-0.1.20-py3-none-any.whl | Python 3 | none | any | Details for bitool-0.1.20-py3-none-any.whl |
Total release size: 2.7 MB
Release files / bitool-0.1.20.tar.gz
| Download URL | bitool-0.1.20.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
84684bafc985a240beeec3e69e07d97115de2b4ce5664616ff41cbfbebc68663
|
|
BLAKE2b-256 checksum How to use checksums |
6690daf696797dc617f9fe794a95c37afa631bbcc9c83ace0b9fa442b6761864
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.17.0 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.13.13"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.5.6 7 Apr 2026","python":"3.13.13","system":{"name":"Windows","release":"11"}} HTTPX2/2.3.0
|
Release files / bitool-0.1.20-py3-none-any.whl
| Download URL | bitool-0.1.20-py3-none-any.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
72d80e01ddd3e075943a041aafcf1479e84703a6b7b184cc00281fff7afc55e9
|
|
BLAKE2b-256 checksum How to use checksums |
2fd920aa20880ce9ae0f3c156a142bfea847d1787ed3c5e6421cb491fbe58a40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.17.0 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.13.13"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.5.6 7 Apr 2026","python":"3.13.13","system":{"name":"Windows","release":"11"}} HTTPX2/2.3.0
|
Security for bitool 0.1.20
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.