-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
90 lines (84 loc) · 2.97 KB
/
setup.py
File metadata and controls
90 lines (84 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# setup.py
import sys
from cx_Freeze import setup, Executable
# --- 基础配置 ---
base_name = "KeyMouse"
base = "Win32GUI" if sys.platform == "win32" else None
# --- 依赖项和数据文件 ---
packages_to_include = [
"pynput",
"tkinter",
"configparser",
"threading",
"queue",
"os", # 常用模块,确保包含
"sys", # 常用模块,确保包含
"json", # 用于IPC的json模块
"ctypes", # 用于管理员权限和Win32 API
"subprocess", # 用于启动子进程
"tempfile", # 用于临时文件
"collections", # 用于scroll_controller
"win_platform", # 项目内部模块
"scroll_controller", # 项目内部模块
"utool", # 项目内部模块
"modeswitch", # 项目内部模块
"config_loader", # 项目内部模块
"gui", # 项目内部模块
"tray_icon", # 项目内部模块
"autostart_manager", # 项目内部模块
"win32con", # pywin32
"win32api", # pywin32
]
# region_selector.py 现在是打包目标,而不是数据文件
files_to_include = [
"config.ini",
# 如果有图标文件,也需要包含
# ("path/to/your/icon.ico", "icon.ico")
]
# --- 构建选项 ---
build_exe_options = {
"packages": packages_to_include,
"includes": [
"pynput.keyboard._win32", # pynput的隐藏导入
"pynput.mouse._win32", # pynput的隐藏导入
"pynput.keyboard", # 确保pynput键盘模块被包含
"pynput.mouse", # 确保pynput鼠标模块被包含
"socket", # 修复:logging.handlers需要socket模块
"logging.handlers", # 确保logging.handlers被包含
],
"include_files": files_to_include,
"excludes": [
"unittest", "test", "distutils", "setuptools", # 排除不需要的模块
"email", "html", "http", "xml", "urllib", # 常见的不需要用于GUI应用的模块
# DEL: "socket", # 移除socket排除,因为logging.handlers需要使用它
"asyncio", "concurrent", "multiprocessing", # 避免与cx_Freeze的多进程处理冲突,但本项目有明确的多进程需求,需谨慎
"numpy", "scipy", "pandas", "matplotlib", # 如果没有科学计算需求,可以排除
],
"optimize": 2,
"silent": True, # 减少构建时的输出
}
# --- 定义要创建的可执行文件 ---
# --- 核心修复:定义两个 Executable 对象 ---
executables = [
# 第一个:主程序
Executable(
"main.py",
base=base,
target_name=f"{base_name}.exe",
# icon="path/to/your/icon.ico"
),
# 第二个:区域选择器
Executable(
"region_selector.py",
base=base, # 同样使用 Win32GUI 来隐藏控制台窗口
target_name="RegionSelector.exe" # 给它一个唯一的名字
)
]
# --- 执行 setup ---
setup(
name=base_name,
version="1.0",
description="A tool to control the mouse with the keyboard.",
options={"build_exe": build_exe_options},
executables=executables, # 使用包含两个目标的列表
)