From 5240b6dc7100e736f72b9cedc48e1f948e3eb5ea Mon Sep 17 00:00:00 2001 From: louisyoungx <1462648167@qq.com> Date: Mon, 22 Nov 2021 21:51:33 +0800 Subject: [PATCH] feat(pack): now can pack all file to exe --- Docs/change-log.md | 4 +++- GUI/pack_requirements.txt | 5 +++++ GUI/packing.py | 29 +++++++++++++++++++++++++++++ README.md | 29 +++++++++++++++++++++++++---- 4 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 GUI/pack_requirements.txt create mode 100644 GUI/packing.py diff --git a/Docs/change-log.md b/Docs/change-log.md index 84d46b0..031f20e 100644 --- a/Docs/change-log.md +++ b/Docs/change-log.md @@ -15,8 +15,10 @@ - 对本地GUI程序进行了初步配置 - 对readme以及文档结构进行修改 -### v1.1.0-计划 +### v1.1.0 - 上线windows开箱即用exe程序 +- 修复windows web ui显示bug +- 更新readme自行打包方法 ### V1.2.0-计划 - 上线价格低于设定值自动下单功能 diff --git a/GUI/pack_requirements.txt b/GUI/pack_requirements.txt new file mode 100644 index 0000000..67f4823 --- /dev/null +++ b/GUI/pack_requirements.txt @@ -0,0 +1,5 @@ +lxml==4.5.1 +bs4==0.0.1 +requests==2.24.0 +pywebview==3.5 +PyInstaller==3.6 \ No newline at end of file diff --git a/GUI/packing.py b/GUI/packing.py new file mode 100644 index 0000000..5b6758a --- /dev/null +++ b/GUI/packing.py @@ -0,0 +1,29 @@ +import os + +RPATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +PATH = RPATH.replace("\\", "/") + + +def run(*commands): + for command in commands: + print(command) + os.system(command) + +pack = f'pyinstaller --noconfirm --onedir --windowed \ +--icon "{PATH}/Static/favicon.ico" \ +--name "jd-shopper" --add-data "{PATH}/Config;Config/" \ +--add-data "{PATH}/cookies;cookies/" \ +--add-data "{PATH}/Core;Core/" \ +--add-data "{PATH}/Docs;Docs/" \ +--add-data "{PATH}/GUI;GUI/" \ +--add-data "{PATH}/Logger;Logger/" \ +--add-data "{PATH}/Message;Message/" \ +--add-data "{PATH}/Scheduler;Scheduler/" \ +--add-data "{PATH}/Server;Server/" \ +--add-data "{PATH}/Static;Static/" \ +--add-data "{PATH}/TEST;TEST/" \ +"{PATH}/runserver.py" \ +' + +if __name__ == '__main__': + run(pack) diff --git a/README.md b/README.md index 5ba38c3..e3cc261 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,12 @@ - 对本地GUI程序进行了初步配置 - 对readme以及文档结构进行修改 -### 即将到来 - +### v1.1.0 - 上线windows开箱即用exe程序 +- 修复windows web ui显示bug +- 更新readme自行打包方法 + +### 即将到来 - 上线价格低于设定值自动下单功能 ## 特别声明: @@ -77,14 +80,14 @@ 安装: ```sh -pip install -r requirements.txt +pip install -r pack_requirements.txt ``` Tips: > > 如果国内安装第三方库比较慢,可以使用以下指令进行清华源加速: > ```sh -> pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/ +> pip install -r pack_requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/ > ``` > > 如果安装错误也可尝试 @@ -160,6 +163,24 @@ python3 main.py 搜索日志,出现“抢购成功,订单号xxxxx",代表成功抢到了,务必半小时内支付订单!程序暂时不支持自动停止,需要手动STOP! 若两分钟还未抢购成功,基本上就是没抢到!程序暂时不支持自动停止,需要手动STOP! +## 自行打包可执行文件 +> 本方法依赖 **PyInstaller**,也可采用其他模块进行打包 +> 打包入口在runserver.py +1. 修改Config/config.ini文件 + ```shell + [GUI] + START_USING=TRUE + ``` +2. 安装打包依赖 +```shell +pip install GUI/pack_requirements.txt +``` +3. 使用 PyInstaller 进行打包 +```shell +python GUI/packing.py +``` +4. 生成可执行文件在 dist/目录中 + ## 感谢 ##### 作者-1 https://github.com/zhou-xiaojun/jd_mask 的开源项目