From 1f3b0ed36545dbd7c4a8369bc75227849651e810 Mon Sep 17 00:00:00 2001 From: skimrme Date: Thu, 5 Feb 2026 15:25:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=B9=B6=E5=AE=8C=E6=88=90wi?= =?UTF-8?q?ndwos=E7=8E=AF=E5=A2=83=E6=89=93=E5=8C=85=EF=BC=8C=E8=BF=99?= =?UTF-8?q?=E6=AC=A1=E7=9C=9F=E7=9A=84=E6=B5=8B=E8=AF=95=EF=BC=8C=E4=BF=9D?= =?UTF-8?q?=E8=AF=81=E5=8F=AF=E4=BB=A5=E8=BF=90=E8=A1=8C=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++- docs/index.html | 1 - windows/build.py | 51 +++++++++++++++++++++++++++++++ windows/command/__init__.py | 0 windows/command/main.py | 18 +++++++++++ windows/main.py | 23 -------------- windows/x86_64_intel_windwos.spec | 38 ----------------------- 7 files changed, 72 insertions(+), 63 deletions(-) delete mode 100644 docs/index.html create mode 100644 windows/build.py delete mode 100644 windows/command/__init__.py create mode 100644 windows/command/main.py delete mode 100644 windows/main.py delete mode 100644 windows/x86_64_intel_windwos.spec diff --git a/.gitignore b/.gitignore index 85d27ec..df45e12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ db/** **/venv/** **/dist/** -**/build/** \ No newline at end of file +**/build/** +*.spec +**/jm_/** \ No newline at end of file diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 9daeafb..0000000 --- a/docs/index.html +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/windows/build.py b/windows/build.py new file mode 100644 index 0000000..9080f25 --- /dev/null +++ b/windows/build.py @@ -0,0 +1,51 @@ +#打包脚本 +import subprocess, os, sys + +# 建立venv虚拟环境 +print("建立venv虚拟环境") +subprocess.run("python -m venv venv", shell=True) + +# 安装requirements.txt中的库 +print("安装requirements.txt中的库") +subprocess.run("venv\\Scripts\\pip.exe install -r ..\\requirements.txt", shell=True) + +# 列出pip安装的库 +print("列出pip安装的库") +subprocess.run("venv\\Scripts\\pip.exe list", shell=True) + +# pyinstaller打包程序 +print("pyinstaller打包中") +print("打包main.py") +subprocess.run("venv\\Scripts\\pyinstaller.exe --onefile command\\main.py", shell=True) +print("打包help.py") +subprocess.run("venv\\Scripts\\pyinstaller.exe --onefile command\\help.py", shell=True) +print("打包Download.py") +subprocess.run("venv\\Scripts\\pyinstaller.exe --onefile command\\Download.py", shell=True) +print("打包version.py") +subprocess.run("venv\\Scripts\\pyinstaller.exe --onefile command\\version.py", shell=True) + +# 清理build和*.spec文件 +print("清理build和*.spec文件") +subprocess.run("RMDIR build /s /q", shell=True) +print("正在清理*.spec文件") +subprocess.run("DEL main.spec version.spec Download.spec help.spec", shell=True) + + +# 重命名dist为jm_ +print("重命名dist为jm_") +dir_path = os.path.dirname(os.path.abspath(__file__)) +print("当前路径: " , f"{dir_path}") +pass +os.rename(f"{dir_path}\\dist", "jm_") + +# 进入打包后产物文件夹 +print("进入打包后产物文件夹") +os.chdir("jm_") + +# 测试程序 +print("测试程序") +subprocess.run("main.exe", shell=True) +subprocess.run("version.exe", shell=True) +subprocess.run("help.exe", shell=True) + +print("大功告成~感谢您的使用") \ No newline at end of file diff --git a/windows/command/__init__.py b/windows/command/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/windows/command/main.py b/windows/command/main.py new file mode 100644 index 0000000..4e1d63b --- /dev/null +++ b/windows/command/main.py @@ -0,0 +1,18 @@ +import sys, subprocess + +# 设定 +if len(sys.argv) == 1: + # 如果什么都没输入就输出 + subprocess.run("help.exe", check=True) + +if len(sys.argv) > 1: + command = sys.argv[1] + + if command == "help": + subprocess.run("help.exe", check=True) + elif command == "jm": + subprocess.run("Download.exe", check=True) + elif command == "version": + subprocess.run("version.exe", check=True) + else: + print(f"未知的命令: {command}") \ No newline at end of file diff --git a/windows/main.py b/windows/main.py deleted file mode 100644 index 58363b4..0000000 --- a/windows/main.py +++ /dev/null @@ -1,23 +0,0 @@ -import sys, os, subprocess -from pathlib import Path - -# 设定使用的python环境 -venv_python = Path(r"./venv/Scripts/python.exe") - - -# 设定 -if len(sys.argv) == 1: - # 如果什么都没输入就输出 - subprocess.run([str(venv_python),".\\command\\help.py"], check=True) - -if len(sys.argv) > 1: - command = sys.argv[1] - - if command == "help": - subprocess.run([str(venv_python),".\\command\\help.py"], check=True) - elif command == "jm": - subprocess.run([str(venv_python),".\\command\\Download.py"], check=True) - elif command == "version": - subprocess.run([str(venv_python),".\\command\\version.py"], check=True) - else: - print(f"未知的命令: {command}") \ No newline at end of file diff --git a/windows/x86_64_intel_windwos.spec b/windows/x86_64_intel_windwos.spec deleted file mode 100644 index fe9528a..0000000 --- a/windows/x86_64_intel_windwos.spec +++ /dev/null @@ -1,38 +0,0 @@ -# -*- mode: python ; coding: utf-8 -*- - - -a = Analysis( - ['main.py'], - pathex=[], - binaries=[], - datas=[('.\\command', 'command')], - hiddenimports=[], - hookspath=[], - hooksconfig={}, - runtime_hooks=[], - excludes=[], - noarchive=False, - optimize=0, -) -pyz = PYZ(a.pure) - -exe = EXE( - pyz, - a.scripts, - a.binaries, - a.datas, - [], - name='x86_64_intel_windwos', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - upx_exclude=[], - runtime_tmpdir=None, - console=True, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch=None, - codesign_identity=None, - entitlements_file=None, -)