提交 39c48e50 编辑于 作者: yuudi's avatar yuudi
浏览文件

fix: reconstruct spec file, linux executable compatibility

上级 83c098b4
......@@ -7,6 +7,7 @@ src/client/*/
!src/client/ybplugins/
!src/client/yybplugins/
!src/client/public/
!src/client/packedfiles/
src/client/.*
src/client/*.json
!src/client/default_*
......@@ -15,7 +16,6 @@ src/client/*.db
src/client/*.db-*
src/client/*.ics
src/client/*.pid
src/client/*.spec
src/client/test.py
.env
cqhttp
......
{
"stable": {
"version": 3476,
"url": "http://img.yobot.xyz/yobot/yobot3459.zip"
"version": 3477,
"url": "http://img.yobot.xyz/yobot/yobot3477.zip"
}
}
\ No newline at end of file
......@@ -2,7 +2,23 @@
## 运行环境
python最低要求为`python3.6`
python最低要求为 `python3.6`
## 打包
安装 `pyinstaller`
```sh
pip install pyinstaller
```
打包程序
```sh
pyinstaller main.spec
```
`dist` 中找到目标文件
## 扩展
......
......@@ -15,14 +15,17 @@ loop=true
while $loop
do
loop=false
python3 main.py -g
{} -g
if [ -f .YOBOT_RESTART ]
then
loop=true
rm .YOBOT_RESTART
fi
done
""")
""".format(
'./yobot' if '_MEIPASS' in dir(sys) else 'python3 main.py'
)
)
print('请通过"sh yobotg.sh"启动')
sys.exit()
if os.path.exists('.YOBOT_RESTART'):
......
# -*- mode: python ; coding: utf-8 -*-
import os
import site
sitepackages = site.getsitepackages()
def sitepackages_location(package_name):
for sp in sitepackages:
if os.path.exists(os.path.join(sp,package_name)):
return sp
raise RuntimeError(f"{package_name} not found")
block_cipher = None
a = Analysis(
['main.py'],
pathex=['.'],
binaries=[],
datas=[
("packedfiles", "packedfiles"),
("public", "public"),
(f"{sitepackages_location('opencc')}/opencc/config", "opencc/config"),
(f"{sitepackages_location('opencc')}/opencc/dictionary", "opencc/dictionary"),
],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='yobot',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
icon='./logo.ico',
)
......@@ -134,6 +134,8 @@ class Updater:
sys.exit()
async def linux_update_async(self, force: bool = False, test_ver: int = 0):
if self.evn == "linux-exe":
return "Linux 便携版暂时无法自动更新"
test_version = ["stable", "beta", "alpha"][test_ver]
pullcheck = self.check_commit(force)
if pullcheck is not None:
......@@ -326,7 +328,7 @@ def rand_vername(seed, length=2):
def get_version(base_version: str, base_commit: int) -> dict:
if "_MEIPASS" in dir(sys):
return {
"run-as": "exe",
"run-as": "exe" if platform.system() == "Windows" else "linux-exe",
"ver_name": "yobot{}便携版".format(base_version),
"ver_id": 3300 + base_commit,
"check_url": [
......
......@@ -34,7 +34,7 @@ else:
class Yobot:
Version = "[v3.6.2_beta]"
Version_id = 176
Version_id = 177
# "git rev-list --count HEAD"
def __init__(self, *,
......@@ -60,7 +60,7 @@ class Yobot:
sys._MEIPASS, "packedfiles", "default_config.json")
else:
default_config_f_path = os.path.join(
os.path.dirname(__file__), "default_config.json")
os.path.dirname(__file__), "packedfiles", "default_config.json")
with open(default_config_f_path, "r", encoding="utf-8") as config_file:
self.glo_setting = json.load(config_file)
if not os.path.exists(config_f_path):
......@@ -73,7 +73,7 @@ class Yobot:
sys._MEIPASS, "packedfiles", "default_boss.json")
else:
default_boss_filepath = os.path.join(
os.path.dirname(__file__), "default_boss.json")
os.path.dirname(__file__), "packedfiles", "default_boss.json")
shutil.copyfile(default_boss_filepath, boss_filepath)
pool_filepath = os.path.join(dirname, "pool3.json")
if not os.path.exists(pool_filepath):
......@@ -82,7 +82,7 @@ class Yobot:
sys._MEIPASS, "packedfiles", "default_pool.json")
else:
default_pool_filepath = os.path.join(
os.path.dirname(__file__), "default_pool.json")
os.path.dirname(__file__), "packedfiles", "default_pool.json")
shutil.copyfile(default_pool_filepath, pool_filepath)
with open(config_f_path, "r+", encoding="utf-8") as config_file:
cfg = json.load(config_file)
......
Supports Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册