- 공통 resolvePython: Windows venv → .venv/bin/python → PIERZAINER_PYTHON → python3/python - 지반 생성·수량산출 Excel·DWG 출력 서버가 같은 해석기 사용, ENOENT 안내 문구 보강 - WSL에서 번들 dwg2dxf.exe 호출 시 wslpath -w로 경로 변환, .exe 실행 권한 부여 - 실제 운곡교 DWG+Excel로 엔진/HTTP 경로 생성 확인(교각16·지형6,545점) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
21 lines
1.2 KiB
TypeScript
21 lines
1.2 KiB
TypeScript
import { existsSync } from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
/**
|
|
* Python used by the local dev-server tools (ground engine, quantity workbook, DWG export).
|
|
* Order: Windows venv → POSIX venv (WSL/Linux) → PIERZAINER_PYTHON → python3/python on PATH.
|
|
*/
|
|
export function resolvePython(root:string,platform:NodeJS.Platform=process.platform,exists:(file:string)=>boolean=existsSync,env:NodeJS.ProcessEnv=process.env):string{
|
|
const venv=path.join(root,'pierzainer_ground','.venv');
|
|
const candidates=platform==='win32'?[path.join(venv,'Scripts','python.exe')]:[path.join(venv,'bin','python'),path.join(venv,'Scripts','python.exe')];
|
|
const found=candidates.find(file=>exists(file));if(found)return found;
|
|
if(env.PIERZAINER_PYTHON)return env.PIERZAINER_PYTHON;
|
|
return platform==='win32'?'python':'python3';
|
|
}
|
|
|
|
/** Human-readable reason for a failed spawn (ENOENT otherwise shows only "spawn python ENOENT"). */
|
|
export function describeSpawnError(error:NodeJS.ErrnoException,python:string):string{
|
|
if(error.code==='ENOENT')return `Python 실행 파일을 찾지 못했습니다(${python}). pierzainer_ground/.venv를 만들고 requirements.txt를 설치하거나 PIERZAINER_PYTHON을 지정하세요.`;
|
|
return error.message;
|
|
}
|