first commit

This commit is contained in:
jack
2025-11-12 11:43:31 +08:00
commit 62948d9d81
31 changed files with 1241 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
import PyInstaller.__main__
import os
import sys
import shutil
# 获取项目根目录的绝对路径
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# 创建 mac 目录
mac_dir = os.path.dirname(os.path.abspath(__file__))
mac_dist_dir = os.path.join(mac_dir, 'dist')
if not os.path.exists(mac_dir):
os.makedirs(mac_dir)
if not os.path.exists(mac_dist_dir):
os.makedirs(mac_dist_dir)
# 设置命令行参数
args = [
os.path.join(ROOT_DIR, 'main.py'), # 主程序入口
'--name=Alpha_Tool', # Mac版本名称
'--onefile', # 打包成单个文件
'--console', # 使用控制台窗口
f'--add-data={os.path.join(ROOT_DIR, "dataset_config.py")}{os.pathsep}.',
f'--add-data={os.path.join(ROOT_DIR, "alpha_strategy.py")}{os.pathsep}.',
f'--add-data={os.path.join(ROOT_DIR, "brain_batch_alpha.py")}{os.pathsep}.',
'--clean',
'--noconfirm',
f'--distpath={mac_dist_dir}',
f'--workpath={os.path.join(mac_dir, "build")}',
f'--specpath={mac_dir}'
]
# 如果有 Mac 图标文件,添加图标
icon_path = os.path.join(mac_dir, 'icon.icns')
if os.path.exists(icon_path):
args.append(f'--icon={icon_path}')
try:
# 运行打包命令
PyInstaller.__main__.run(args)
# 打包完成后,复制或创建配置文件到 dist 目录
print("\n正在处理配置文件...")
# 处理认证文件
credentials_src = os.path.join(ROOT_DIR, 'brain_credentials.txt')
if os.path.exists(credentials_src):
shutil.copy2(credentials_src, mac_dist_dir)
print("✅ brain_credentials.txt 复制成功")
else:
with open(os.path.join(mac_dist_dir, 'brain_credentials.txt'), 'w') as f:
f.write('["your_email@example.com","your_password"]')
print("✅ 创建了示例 brain_credentials.txt")
# 处理 Alpha ID 文件
alpha_ids_src = os.path.join(ROOT_DIR, 'alpha_ids.txt')
if os.path.exists(alpha_ids_src):
shutil.copy2(alpha_ids_src, mac_dist_dir)
print("✅ alpha_ids.txt 复制成功")
else:
with open(os.path.join(mac_dist_dir, 'alpha_ids.txt'), 'w') as f:
...
print("✅ 创建了空的 alpha_ids.txt")
print(f"\n✅ Mac 版本打包完成! 文件位于 {mac_dist_dir}")
except Exception as e:
print(f"\n❌ 打包过程出错: {str(e)}")
sys.exit(1)
+48
View File
@@ -0,0 +1,48 @@
import os
from PIL import Image
def create_icns():
"""创建 .icns 文件"""
try:
# 检查源图片
png_path = os.path.join(os.path.dirname(__file__), 'icon.png')
if not os.path.exists(png_path):
print("⚠️ 未找到 icon.png,将创建默认图标")
# 创建一个简单的默认图标
img = Image.new('RGB', (512, 512), color='white')
img.save(png_path)
# 创建临时 iconset 目录
iconset_name = "icon.iconset"
if not os.path.exists(iconset_name):
os.makedirs(iconset_name)
# 需要的图标尺寸
icon_sizes = [16, 32, 64, 128, 256, 512]
# 打开原始图片
img = Image.open(png_path)
# 生成不同尺寸的图标
for size in icon_sizes:
img_copy = img.copy()
img_copy.thumbnail((size, size), Image.Resampling.LANCZOS)
img_copy.save(f"{iconset_name}/icon_{size}x{size}.png")
# 使用 iconutil 创建 .icns 文件(仅在 Mac 上可用)
if os.system('which iconutil') == 0:
os.system(f'iconutil -c icns {iconset_name}')
else:
print("⚠️ iconutil 不可用,跳过 .icns 创建")
print("✅ 图标处理完成")
except Exception as e:
print(f"❌ 创建图标时出错: {str(e)}")
# 不抛出异常,让构建继续进行
if __name__ == "__main__":
create_icns()
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB