chore: stabilize Zhinian pilot delivery

This commit is contained in:
inman
2026-05-12 19:44:44 +08:00
parent 45389855e1
commit 20b5aff4ad
174 changed files with 41428 additions and 784 deletions

View File

@@ -9,7 +9,7 @@ import { quoteForCmd, needsWinShell } from './paths';
/**
* Get the path to the bundled uv binary
*/
function getBundledUvPath(): string {
export function getBundledUvPath(): string {
const platform = process.platform;
const arch = process.arch;
const target = `${platform}-${arch}`;
@@ -29,7 +29,7 @@ function getBundledUvPath(): string {
* pick up a system-wide uv that may be a different (possibly broken) version.
* In dev we fall through to the system PATH for convenience.
*/
function resolveUvBin(): { bin: string; source: 'bundled' | 'path' | 'bundled-fallback' } {
export function resolveUvBin(): { bin: string; source: 'bundled' | 'path' | 'bundled-fallback' } {
const bundled = getBundledUvPath();
if (app.isPackaged) {
@@ -88,19 +88,30 @@ export async function installUv(): Promise<void> {
* Check if a managed Python 3.12 is ready and accessible
*/
export async function isPythonReady(): Promise<boolean> {
return Boolean(await findManagedPythonPath());
}
/**
* Return the uv-managed Python 3.12 executable path when available.
*/
export async function findManagedPythonPath(): Promise<string | null> {
const { bin: uvBin } = resolveUvBin();
const useShell = needsWinShell(uvBin);
return new Promise<boolean>((resolve) => {
return new Promise<string | null>((resolve) => {
try {
const child = spawn(useShell ? quoteForCmd(uvBin) : uvBin, ['python', 'find', '3.12'], {
shell: useShell,
windowsHide: true,
});
child.on('close', (code) => resolve(code === 0));
child.on('error', () => resolve(false));
let stdout = '';
child.stdout?.on('data', (data) => {
stdout += data.toString();
});
child.on('close', (code) => resolve(code === 0 ? stdout.trim() || null : null));
child.on('error', () => resolve(null));
} catch {
resolve(false);
resolve(null);
}
});
}
@@ -206,19 +217,8 @@ export async function setupManagedPython(): Promise<void> {
}
// After installation, verify and log the Python path
const verifyShell = needsWinShell(uvBin);
try {
const findPath = await new Promise<string>((resolve) => {
const child = spawn(verifyShell ? quoteForCmd(uvBin) : uvBin, ['python', 'find', '3.12'], {
shell: verifyShell,
env: { ...process.env, ...uvEnv },
windowsHide: true,
});
let output = '';
child.stdout?.on('data', (data) => { output += data; });
child.on('close', () => resolve(output.trim()));
});
const findPath = await findManagedPythonPath();
if (findPath) {
logger.info(`Managed Python 3.12 installed at: ${findPath}`);
}