Skip to content

Commit d68ee79

Browse files
committed
feat: 不再使用覆盖层
1 parent 76bd047 commit d68ee79

17 files changed

Lines changed: 116 additions & 564 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- 修复一些 Mac napcat注入问题
66
- 修复一些未知问题
7+
- 优化了python管理和依赖安装的逻辑
78

89
## 0.4.16 - 2026-07-03
910

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ bun run build
4545

4646
## 运行时资源
4747

48-
打包版默认把可写运行资源放在 `%APPDATA%\MaiBotOneKeyDesktop\<安装目录hash>` 下;设置中心的「实例路径」页可以迁移运行时资源目录。迁移只移动 `modules/``python-overrides/`,日志、实例锁和一键包设置仍保留在用户数据目录
48+
打包版默认把可写运行资源放在 `%APPDATA%\MaiBotOneKeyDesktop\<安装目录hash>` 下;设置中心的「实例路径」页可以迁移运行时资源目录。迁移只移动 `modules/`,日志、实例锁、`python-env` 和一键包设置仍保留在用户数据目录
4949

5050
## Windows 打包
5151

52-
Windows x64 NSIS 安装包当前产出正式版:`MaiBot OK-<version>-win.exe`。正式版会打包干净的基础 Python、内置 Git、MaiBot、NapCat、SnowLuma 以及 NapCat/SnowLuma 适配器插件,但不会打包 MaiBot Python 依赖,也不会打包 `python-overrides` 覆盖层;首次启动时再由启动器安装运行依赖
52+
Windows x64 NSIS 安装包当前产出正式版:`MaiBot OK-<version>-win.exe`。正式版会打包干净的基础 Python、内置 Git、MaiBot、NapCat、SnowLuma 以及 NapCat/SnowLuma 适配器插件,但不会把 MaiBot Python 依赖预装进包内 runtime;首次启动时启动器会复制一份可写 `python-env` 并把运行依赖安装到其中
5353

5454
打包前需要在仓库根目录放好 payload:
5555

@@ -73,7 +73,7 @@ modules/
7373
SnowLuma/
7474
```
7575

76-
`runtime/python` 必须保持为便携 Python,只允许 Python 自身、`pip`/`setuptools`/`wheel` 以及启动依赖解析需要的 `packaging`;不要把 MaiBot、dashboard 或其它应用依赖预装进 `runtime/python/Lib/site-packages`。macOS 包内路径是 `runtime/python/bin/python3`,Windows 包内路径是 `runtime/python/python.exe``release-assets/python-overrides` 不会进入安装包
76+
`runtime/python` 必须保持为便携 Python,只允许 Python 自身、`pip`/`setuptools`/`wheel` 以及启动依赖解析需要的 `packaging`;不要把 MaiBot、dashboard 或其它应用依赖预装进 `runtime/python/Lib/site-packages`。macOS 包内路径是 `runtime/python/bin/python3.12` 或同版本真实二进制,Windows 包内路径是 `runtime/python/python.exe`
7777

7878
编写器里的 OpenCode 入口依赖内置 CLI sidecar:打包前需要把 Windows x64 版 `opencode.exe` 放到 `runtime/opencode/opencode.exe`。当前接入按 `opencode-windows-x64` release binary 设计,`runtime/` 已被 `.gitignore` 忽略,所以该二进制不会进入源码提交;`bun run release:check` 会校验它是否存在。
7979

docs/release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
modules/SnowLuma/index.mjs
2828
```
2929

30-
`runtime/python` 必须保持为便携 Python,只保留 Python 自身、`pip`/`setuptools`/`wheel` 以及启动依赖解析需要的 `packaging`。不要把 MaiBot、dashboard 或其它应用依赖预装进 `runtime/python/Lib/site-packages``runtime/python/lib/python3.12/site-packages``release-assets/python-overrides` 不会进入安装包
30+
`runtime/python` 必须保持为便携 Python,只保留 Python 自身、`pip`/`setuptools`/`wheel` 以及启动依赖解析需要的 `packaging`。不要把 MaiBot、dashboard 或其它应用依赖预装进 `runtime/python/Lib/site-packages``runtime/python/lib/python3.12/site-packages`首次启动会复制可写 `python-env` 并把运行依赖安装到其中
3131

3232
`resources/opencode/plugin_code.md` 会在打包时复制到安装包资源目录的 `runtime/opencode/plugin_code.md`,用于编写器内置 OpenCode 的默认插件编写说明。
3333

scripts/release/check-windows-payload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ async function main(): Promise<void> {
409409
console.log("");
410410
console.log("[missing] portable Python should not contain application dependencies.");
411411
console.log("Keep runtime/python lean: only Python itself plus pip/setuptools/wheel/packaging are allowed.");
412-
console.log("Install MaiBot/dashboard dependencies into python-overrides at first run instead.");
412+
console.log("Install MaiBot/dashboard dependencies into the writable python-env at first run instead.");
413413
if (bundledPythonPackages.length > 0) {
414414
console.log(`Unexpected site-packages entries (${bundledPythonPackages.length}):`);
415415
for (const name of bundledPythonPackages.slice(0, 30)) {

scripts/release/prepare-python-overrides.ts

Lines changed: 0 additions & 155 deletions
This file was deleted.

src/main/ipc/app.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ import type {
9898
ModuleSourceUpdate,
9999
ModuleTagOption,
100100
ModuleUpdateTarget,
101-
PythonOverridesState,
101+
PythonEnvironmentState,
102102
PythonPackageSourcePreset,
103103
PythonPackageInstallRequest,
104104
PythonPackageInstallResult,
@@ -2141,12 +2141,12 @@ export function registerAppIpc({
21412141
}
21422142

21432143
const dashboardVersion = await readPythonDistInfoVersion(
2144-
pythonDependencyManager.getActiveOverridesRoot(),
2144+
pythonDependencyManager.getPythonPackagesRoot(),
21452145
"maibot-dashboard",
21462146
);
21472147
if (dashboardVersion) {
2148-
versions.dashboardOverride = dashboardVersion;
2149-
versions.dashboardOverrideSource = "python-overrides";
2148+
versions.dashboardPythonEnv = dashboardVersion;
2149+
versions.dashboardPythonEnvSource = "python-env";
21502150
}
21512151

21522152
return versions;
@@ -3749,7 +3749,7 @@ export function registerAppIpc({
37493749
},
37503750
);
37513751

3752-
ipcMain.handle("pythonDeps:getState", (): PythonOverridesState => {
3752+
ipcMain.handle("pythonDeps:getState", (): PythonEnvironmentState => {
37533753
return pythonDependencyManager.getState();
37543754
});
37553755

@@ -3758,7 +3758,7 @@ export function registerAppIpc({
37583758
async (
37593759
_event,
37603760
preset: PythonPackageSourcePreset,
3761-
): Promise<PythonOverridesState> => {
3761+
): Promise<PythonEnvironmentState> => {
37623762
const state = await pythonDependencyManager.saveSourcePreset(preset);
37633763
await broadcastSnapshot();
37643764
return state;

src/main/services/init-manager.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ const MAIBOT_WEBUI_FALLBACK_PORT = 8001;
5656
const QQ_BACKEND_FILE = "qq-backend.json";
5757
const MESSAGE_PLATFORM_FILE = "message-platform.json";
5858
const RUNTIME_PATH_CONFIG_FILE = "runtime-paths.json";
59-
const PYTHON_OVERRIDES_IGNORED_ENTRIES = new Set([".keep", "resource.lock"]);
6059
const NAPCAT_COMPONENT_PROTECTED_PATHS = [
6160
"config",
6261
"data",
@@ -3006,44 +3005,6 @@ export class InitManager {
30063005
}
30073006
}
30083007

3009-
async ensureBundledPythonOverrides(): Promise<string[]> {
3010-
const bundledRoot = join(dirname(this.paths.runtimeRoot), "python-overrides");
3011-
const targetRoot = this.paths.pythonOverridesRoot;
3012-
if (!existsSync(bundledRoot) || samePath(bundledRoot, targetRoot)) {
3013-
return [];
3014-
}
3015-
3016-
let bundledEntries: string[];
3017-
try {
3018-
bundledEntries = (await readdir(bundledRoot)).filter((entry) => !PYTHON_OVERRIDES_IGNORED_ENTRIES.has(entry));
3019-
} catch {
3020-
return [];
3021-
}
3022-
if (bundledEntries.length === 0) {
3023-
return [];
3024-
}
3025-
3026-
let targetEntries: string[] = [];
3027-
try {
3028-
targetEntries = (await readdir(targetRoot)).filter((entry) => !PYTHON_OVERRIDES_IGNORED_ENTRIES.has(entry));
3029-
} catch {
3030-
targetEntries = [];
3031-
}
3032-
if (targetEntries.length > 0) {
3033-
return [];
3034-
}
3035-
3036-
await mkdir(dirname(targetRoot), { recursive: true });
3037-
await runWithoutAsar(() =>
3038-
cp(bundledRoot, targetRoot, {
3039-
recursive: true,
3040-
force: false,
3041-
errorOnExist: false,
3042-
}),
3043-
);
3044-
return [targetRoot];
3045-
}
3046-
30473008
/**
30483009
* Generate a fixed launcher .cmd under the napcat directory; it runs chcp 65001 before the exe.
30493010
* Avoid building a `cmd /C` command string in source while keeping the console in UTF-8.

src/main/services/paths.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ function defaultResourcePaths(defaultResourceRoot: string): RuntimeResourcePathM
4040
return {
4141
maibot: join(defaultResourceRoot, "modules", "MaiBot"),
4242
napcat: join(defaultResourceRoot, "modules", "napcat"),
43-
pythonOverrides: join(defaultResourceRoot, "python-overrides"),
4443
};
4544
}
4645

@@ -52,7 +51,6 @@ function readStoredResourcePaths(userDataRoot: string): Partial<RuntimeResourceP
5251
return {
5352
maibot: normalizePath(raw.paths?.maibot),
5453
napcat: normalizePath(raw.paths?.napcat),
55-
pythonOverrides: normalizePath(raw.paths?.pythonOverrides),
5654
};
5755
} catch {
5856
return {};
@@ -80,9 +78,6 @@ export function applyRuntimeResourcePaths(paths: RuntimePaths, updates: Partial<
8078
if (updates.napcat) {
8179
paths.napcatRoot = updates.napcat;
8280
}
83-
if (updates.pythonOverrides) {
84-
paths.pythonOverridesRoot = updates.pythonOverrides;
85-
}
8681
paths.resourceRoot = paths.defaultResourceRoot;
8782
paths.modulesRoot = join(paths.defaultResourceRoot, "modules");
8883
}
@@ -116,8 +111,7 @@ export function configureRuntimePaths(): RuntimePaths {
116111
opencodePluginInstructionsPath: app.isPackaged
117112
? join(payloadRoot, "runtime", "opencode", "plugin_code.md")
118113
: join(installRoot, "resources", "opencode", "plugin_code.md"),
119-
defaultPythonOverridesRoot: defaults.pythonOverrides,
120-
pythonOverridesRoot: defaults.pythonOverrides,
114+
pythonEnvRoot: join(defaultResourceRoot, "python-env"),
121115
pluginBuilderRoot: join(userDataRoot, "plugin-builder", "plugins"),
122116
logsRoot: join(userDataRoot, "logs"),
123117
};

0 commit comments

Comments
 (0)