uvinstaller
🚀 uvinstaller 是一个自动化Python应用打包工具,使用 uv 和 pyinstaller 将Python脚本打包成单个可执行文件。
✨ 特性
- 🔧 自动安装uv: 如果系统中没有uv,会自动下载安装
- 📦 智能依赖分析: 自动分析Python文件的所有依赖关系
- 🌏 虚拟环境隔离: 使用uv创建干净的虚拟环境进行打包
- 📱 单文件输出: 生成单个可执行文件,便于分发
- 🧹 自动清理: 打包完成后自动清理临时文件
- 🖥️ 跨平台支持: 支持Windows、Linux、macOS
🚀 快速开始
安装
pip install uvinstaller
使用
uvi your_script.py
就是这么简单!工具会自动:
- 检查并安装uv环境
- 分析脚本的所有依赖
- 创建虚拟环境并安装依赖
- 使用pyinstaller打包
- 将可执行文件复制到源码目录
📋 使用示例
基本用法
# 打包单个Python文件
uvi app.py
# 打包带路径的文件
uvi src/main.py
支持的文件结构
my_project/
├── main.py # 主入口文件
├── utils.py # 本地模块
├── config/ # 本地包
│ └── __init__.py
└── requirements.txt # 依赖文件(可选)
运行 uvi main.py 会自动:
- 分析
main.py的导入 - 扫描同目录下的所有Python文件
- 读取
requirements.txt(如果存在) - 安装所有必要的依赖
🔧 工作原理
- 环境检查: 检查系统是否有uv,没有则自动安装
- 依赖分析: 使用AST分析Python文件的导入语句
- 环境创建: 使用uv创建临时虚拟环境
- 依赖安装: 在虚拟环境中安装pyinstaller和项目依赖
- 文件复制: 复制源码到临时目录
- 执行打包: 使用pyinstaller生成单文件可执行程序
- 文件复制: 将可执行文件复制到源码目录
- 清理临时文件: 删除所有临时文件和目录
🎯 适用场景
- 🖥️ 桌面应用: 将Python GUI应用打包为exe
- 🔧 命令行工具: 将脚本打包为可执行工具
- 📊 数据处理脚本: 打包数据分析脚本
- 🌐 自动化脚本: 打包运维和自动化脚本
- 🎮 游戏和娱乐: 打包Python游戏
📁 项目结构
uvinstaller/
├── src/
│ └── uvinstaller/
│ ├── __init__.py
│ ├── cli.py # 命令行接口
│ ├── uv_installer.py # uv自动安装
│ ├── dependency_analyzer.py # 依赖分析
│ └── packager.py # 打包器
├── pyproject.toml # 项目配置
├── build_and_publish.py # 构建发布脚本
└── README.md
🛠️ 开发
本地开发环境
# 克隆代码
git clone https://github.com/uvinstaller/uvinstaller.git
cd uvinstaller
# 安装开发依赖
uv pip install -e ".[dev]"
# 运行测试
pytest
构建和发布
使用提供的构建脚本:
python build_and_publish.py
脚本会自动:
- 清理构建目录
- 安装构建依赖
- 构建wheel和源码包
- 检查包的完整性
- 可选上传到PyPI
🤝 贡献
欢迎提交Issue和Pull Request!
- Fork项目
- 创建特性分支
- 提交更改
- 推送到分支
- 创建Pull Request
📄 许可证
MIT License - 详见 LICENSE 文件
🙏 致谢
- uv - 快速Python包管理器
- PyInstaller - Python应用打包工具
📞 支持
如果遇到问题或有建议,请:
- 查看 Issues
- 创建新的Issue
- 联系维护者
⭐ 如果这个项目对你有帮助,请给我们一个星标!
Metadata
Release files for uvinstaller 1.0.0
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 |
|---|---|---|---|---|
| uvinstaller-1.0.0.tar.gz | 11.8 kB | Without provenance | Details for uvinstaller-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uvinstaller-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for uvinstaller-1.0.0-py3-none-any.whl |
Total release size: 25.9 kB
Release files / uvinstaller-1.0.0.tar.gz
| Download URL | uvinstaller-1.0.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db8587d725ac576fed1178768d7261088945f6cc0cbc3a3fd5a1aa87c68bd042
|
|
BLAKE2b-256 checksum How to use checksums |
d873528925232f7c84c433a25c4da228404e0fe4d5a81879cc43b33873222d08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / uvinstaller-1.0.0-py3-none-any.whl
| Download URL | uvinstaller-1.0.0-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bdccd478c44dcfdab5522f6ce82fe287cb004ae030c704d4d51a51d5630d3d8f
|
|
BLAKE2b-256 checksum How to use checksums |
8a7d25143c927790f10b5ed366edb36e4cbe7fa23ab562d558beb608899a93f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Security for uvinstaller 1.0.0
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.