Pyupdater自动更新
安装
pip install pyupdater==4.0
使用
其他机器上执行
在其他机器上生成密钥,将生成的密钥放置在使用pyinstaller的项目的根目录。
开发机器上执行
清空配置:
初始化pyupdater
pyupdater init
输入的应用名称要和生成秘钥时的名称一致,执行完成后,会在项目的根目录生成一个client_config.py
示例:
(venv) D:\python_workspace\AdbKit>pyupdater init
[INFO] PyUpdater 4.0
192 INFO: PyUpdater 4.0
Please enter app name
[DEFAULT] -> PyUpdater App
Press Enter To Use Default
--> TestKit
You entered TestKit, is this correct?
[N/y]?y
Please enter your name or company name
[DEFAULT] -> PyUpdater App
Press Enter To Use Default
--> yinkanghong
You entered yinkanghong, is this correct?
[N/y]?y
Enter a url to ping for updates. - No Default Available
--> http://10.241.132.118:5080/static/testkit
You entered http://10.241.132.118:5080/static/testkit, is this correct?
[N/y]?y
Would you like to add another url for backup?
[N/y]?n
Would you like to enable patch updates?
[Y/n]?y
Please enter the path to where pyupdater will write the client_config.py file. You'll need to import this file to initialize the update process.
Examples:
lib/utils, src/lib, src.
Leave blank to use the current directory
[DEFAULT] -> AdbKit
Press Enter To Use Default
-->
You entered AdbKit, is this correct?
[N/y]?y
[INFO] Creating pyu-data dir...
27219 INFO: Creating pyu-data dir...
27220 DEBUG: Creating config dir
27220 DEBUG: Config Dir: D:\python_workspace\AdbKit\.pyupdater
27220 DEBUG: Config DB: D:\python_workspace\AdbKit\.pyupdater\config.pyu
27220 DEBUG: Config Dir: D:\python_workspace\AdbKit\.pyupdater
27221 DEBUG: Config DB: D:\python_workspace\AdbKit\.pyupdater\config.pyu
27221 DEBUG: Config Dir: D:\python_workspace\AdbKit\.pyupdater
27221 DEBUG: Config DB: D:\python_workspace\AdbKit\.pyupdater\config.pyu
[INFO] Creating dir: D:\python_workspace\AdbKit\pyu-data\new
27221 INFO: Creating dir: D:\python_workspace\AdbKit\pyu-data\new
[INFO] Creating dir: D:\python_workspace\AdbKit\pyu-data\deploy
27221 INFO: Creating dir: D:\python_workspace\AdbKit\pyu-data\deploy
27239 DEBUG: Saving Config
27239 DEBUG: Syncing db to filesystem
27240 DEBUG: Config saved
27240 DEBUG: *** Keypack data is None ***
27240 DEBUG: Writing client_config.py
27240 DEBUG: Adding PUBLIC_KEY to client_config.py
27241 DEBUG: Adding APP_NAME to client_config.py
27241 DEBUG: Adding COMPANY_NAME to client_config.py
27241 DEBUG: Adding HTTP_TIMEOUT to cilent_config.py
27242 DEBUG: Adding MAX_DOWNLOAD_RETRIES to client_config.py
27242 DEBUG: Adding UPDATE_URLS to client_config.py
27242 DEBUG: Wrote client config
[INFO] Setup complete
27242 INFO: Setup complete
导入秘钥
pyupdater keys --import
执行完成后,client_config.py 中PUBLIC_KEY将有值
生成spec文件
pyinstaller的spec文件和pyupdater不共用 pyupdater需要重新生成,不可以直接使用之前pyinstaller的。
pyupdater make-spec --add-data "adb;adb" --add-data "autotest;autotest" --add-data "common;common" --add-data "scrcpy;sc
rcpy" --add-data "templates;templates" --add-data "static;static" --add-data "scrcpy-win64-v1.24;scrcpy-win64-v1.24" -w adb_kit.py
打包
完成后将在 pyu-data/new 目录中看到打包完成的产物错误1
Q: FileNotFoundError: [Errno 2] No such file or directory: 'TestKit\win.exe.manifest' A: https://github.com/Digital-Sapphire/PyUpdater/issues/304 在 win.spec 中 在EXE配置里添加 embed_manifest=False,
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='win',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
embed_manifest=False,
)
错误2
Q: FileNotFoundError: [WinError 3] 系统找不到指定的路径。: 'win'
签名
签名后,产物将从 pyu-data/new 目录移动至 pyu-data/deploy 目录。错误1
Q: AttributeError: 'LegacyVersion' object has no attribute 'major' A: pip install dsdev-utils==1.0.5 安装指定版本即可
https://github.com/Digital-Sapphire/PyUpdater/issues/299