测试并完成windwos环境打包,这次真的测试,保证可以运行了
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +1,6 @@
|
||||
db/**
|
||||
**/venv/**
|
||||
**/dist/**
|
||||
**/build/**
|
||||
**/build/**
|
||||
*.spec
|
||||
**/jm_/**
|
||||
@@ -1 +0,0 @@
|
||||
test
|
||||
51
windows/build.py
Normal file
51
windows/build.py
Normal file
@@ -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("大功告成~感谢您的使用")
|
||||
18
windows/command/main.py
Normal file
18
windows/command/main.py
Normal file
@@ -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}")
|
||||
@@ -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}")
|
||||
@@ -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,
|
||||
)
|
||||
Reference in New Issue
Block a user