自动安装UPX可执行文件到Windows系统
Project description
UPX Installer
一个Python包,自动安装UPX可执行文件到Windows系统的C:\Windows目录。
功能特性
- 自动安装: 安装Python包时自动将UPX复制到C:\Windows目录
- 卸载功能: 提供完整的卸载功能,可恢复备份文件
- 验证机制: 验证UPX安装的正确性
- 备份恢复: 安装时自动备份现有UPX文件
- 跨平台: 虽然主要针对Windows,但在其他系统上也可安全安装(不复制文件)
安装方法
从PyPI安装(推荐)
pip install upx-installer
安装完成后,UPX将自动安装到C:\Windows目录。
手动安装(开发模式)
# 克隆仓库
git clone https://github.com/example/upx-installer.git
cd upx-installer
# 安装开发版本
pip install -e .
使用方法
命令行工具
安装后,可以使用 upx-installer 命令行工具:
# 安装UPX(如果未自动安装)
upx-installer install
# 强制重新安装
upx-installer install --force
# 安装时不创建备份
upx-installer install --no-backup
# 卸载UPX
upx-installer uninstall
# 卸载并恢复备份
upx-installer uninstall --restore-backup
# 验证安装
upx-installer verify
# 检查UPX版本
upx-installer version
Python API
import upx_installer
# 安装UPX
upx_installer.install_upx()
# 强制安装
upx_installer.install_upx(force=True)
# 卸载UPX
upx_installer.uninstall_upx()
# 验证安装
upx_installer.verify_installation()
权限要求
在Windows系统上,写入C:\Windows目录需要管理员权限。如果遇到权限错误:
- 以管理员身份运行命令提示符/PowerShell
- 或手动将UPX复制到C:\Windows目录
技术细节
文件位置
- UPX源文件: 包内的
upx_installer/data/upx.exe - 安装目标:
C:\Windows\upx.exe - 安装记录:
%USERPROFILE%\.upx_installer_record.json - 备份文件:
%USERPROFILE%\.upx_installer_backup\
安装验证
安装时会计算UPX文件的MD5哈希值并保存到安装记录中。验证时比较当前文件的哈希值与记录值,确保文件未被修改。
开发指南
环境设置
# 安装开发依赖
pip install -e ".[dev]"
# 运行测试
pytest tests/
构建包
# 构建源码包和wheel
python setup.py sdist bdist_wheel
# 或使用build工具
python -m build
发布到PyPI
# 上传到PyPI
twine upload dist/*
常见问题
Q: 安装时出现权限错误怎么办?
A: 请以管理员身份运行命令提示符或PowerShell,然后重新安装。
Q: 非Windows系统可以使用吗?
A: 可以安装包,但不会复制UPX文件(因为目标路径是C:\Windows)。
Q: 如何手动安装UPX?
A: 只需将UPX可执行文件复制到C:\Windows目录或系统PATH中的任何目录。
Q: 这个包包含UPX的哪个版本?
A: 包含当前包版本的UPX可执行文件。使用 upx-installer version 查看具体版本。
许可证
MIT License - 详见 LICENSE 文件。
贡献
欢迎提交Issue和Pull Request!
- Fork仓库
- 创建功能分支 (
git checkout -b feature/amazing-feature) - 提交更改 (
git commit -m 'Add amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 开启Pull Request
免责声明
本软件按"原样"提供,不提供任何明示或暗示的担保。使用UPX请遵守其原始许可证。
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
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
File details
Details for the file upx_installer-1.0.0.tar.gz.
File metadata
- Download URL: upx_installer-1.0.0.tar.gz
- Upload date:
- Size: 533.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a13f8a7159ef953e1fb2d201b653402088a55ea32f8c7f19f3feae0375bbcf68
|
|
| MD5 |
0746f07608a7dc9f842c0164c53c2a19
|
|
| BLAKE2b-256 |
7ffa6c065041808d2eb16f07ed84ce26a796452bfcca28a26594a62cbf2472d1
|
File details
Details for the file upx_installer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: upx_installer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 531.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b091007f7b33636ff31d04e6d08fe3be031653b378efb9d78018a1c15c5165e3
|
|
| MD5 |
bbb5e253cf377cab9fff8ab976713a32
|
|
| BLAKE2b-256 |
7a2a06b3cc2984c59122927d6c55a3a99035a4aeb83a4d5dc46811c48c955373
|