fix: 修复已知问题

This commit is contained in:
hp0912 2026-05-02 00:57:36 +08:00
parent d9a8f59093
commit 40d6077398
10 changed files with 105 additions and 15 deletions

View File

@ -49,8 +49,14 @@ def _ensure_venv(venv_dir: Path, venv_python: Path) -> int:
return 0
sys.stdout.write(f"未检测到技能虚拟环境,正在创建: {venv_dir}\n")
import shutil
py = sys.executable or next(
(shutil.which(c) for c in ("python3", "python") if shutil.which(c)), None
)
if not py:
raise RuntimeError("无法找到 Python 解释器路径")
command = [
sys.executable,
py,
"-m",
"venv",
str(venv_dir),

View File

@ -31,9 +31,20 @@ def _skill_venv_python() -> Path:
return venv_dir / "bin" / "python"
def _get_python_executable() -> str:
if sys.executable:
return sys.executable
import shutil
for candidate in ("python3", "python"):
found = shutil.which(candidate)
if found:
return found
raise RuntimeError("无法找到 Python 解释器路径")
def _run_bootstrap() -> None:
bootstrap = Path(__file__).resolve().parent / "bootstrap.py"
result = subprocess.run([sys.executable, str(bootstrap)])
result = subprocess.run([_get_python_executable(), str(bootstrap)])
if result.returncode != 0:
raise SystemExit(result.returncode)
@ -60,7 +71,8 @@ try:
import pymysql # type: ignore # noqa: E402
except ModuleNotFoundError:
_run_bootstrap()
os.execv(sys.executable, [sys.executable, str(Path(__file__).resolve()), *sys.argv[1:]])
_py = _get_python_executable()
os.execv(_py, [_py, str(Path(__file__).resolve()), *sys.argv[1:]])
def _mysql_connect():

View File

@ -49,8 +49,14 @@ def _ensure_venv(venv_dir: Path, venv_python: Path) -> int:
return 0
sys.stdout.write(f"未检测到技能虚拟环境,正在创建: {venv_dir}\n")
import shutil
py = sys.executable or next(
(shutil.which(c) for c in ("python3", "python") if shutil.which(c)), None
)
if not py:
raise RuntimeError("无法找到 Python 解释器路径")
command = [
sys.executable,
py,
"-m",
"venv",
str(venv_dir),

View File

@ -29,9 +29,20 @@ def _skill_venv_python() -> Path:
return venv_dir / "bin" / "python"
def _get_python_executable() -> str:
if sys.executable:
return sys.executable
import shutil
for candidate in ("python3", "python"):
found = shutil.which(candidate)
if found:
return found
raise RuntimeError("无法找到 Python 解释器路径")
def _run_bootstrap() -> None:
bootstrap = Path(__file__).resolve().parent / "bootstrap.py"
result = subprocess.run([sys.executable, str(bootstrap)])
result = subprocess.run([_get_python_executable(), str(bootstrap)])
if result.returncode != 0:
raise SystemExit(result.returncode)
@ -58,7 +69,8 @@ try:
import pymysql # type: ignore # noqa: E402
except ModuleNotFoundError:
_run_bootstrap()
os.execv(sys.executable, [sys.executable, str(Path(__file__).resolve()), *sys.argv[1:]])
_py = _get_python_executable()
os.execv(_py, [_py, str(Path(__file__).resolve()), *sys.argv[1:]])
# ---------------------------------------------------------------------------

View File

@ -49,8 +49,14 @@ def _ensure_venv(venv_dir: Path, venv_python: Path) -> int:
return 0
sys.stdout.write(f"未检测到技能虚拟环境,正在创建: {venv_dir}\n")
import shutil
py = sys.executable or next(
(shutil.which(c) for c in ("python3", "python") if shutil.which(c)), None
)
if not py:
raise RuntimeError("无法找到 Python 解释器路径")
command = [
sys.executable,
py,
"-m",
"venv",
str(venv_dir),

View File

@ -29,9 +29,20 @@ def _skill_venv_python() -> Path:
return venv_dir / "bin" / "python"
def _get_python_executable() -> str:
if sys.executable:
return sys.executable
import shutil
for candidate in ("python3", "python"):
found = shutil.which(candidate)
if found:
return found
raise RuntimeError("无法找到 Python 解释器路径")
def _run_bootstrap() -> None:
bootstrap = Path(__file__).resolve().parent / "bootstrap.py"
result = subprocess.run([sys.executable, str(bootstrap)])
result = subprocess.run([_get_python_executable(), str(bootstrap)])
if result.returncode != 0:
raise SystemExit(result.returncode)
@ -58,7 +69,8 @@ try:
import pymysql # type: ignore # noqa: E402
except ModuleNotFoundError:
_run_bootstrap()
os.execv(sys.executable, [sys.executable, str(Path(__file__).resolve()), *sys.argv[1:]])
_py = _get_python_executable()
os.execv(_py, [_py, str(Path(__file__).resolve()), *sys.argv[1:]])
# ---------------------------------------------------------------------------

View File

@ -49,8 +49,14 @@ def _ensure_venv(venv_dir: Path, venv_python: Path) -> int:
return 0
sys.stdout.write(f"未检测到技能虚拟环境,正在创建: {venv_dir}\n")
import shutil
py = sys.executable or next(
(shutil.which(c) for c in ("python3", "python") if shutil.which(c)), None
)
if not py:
raise RuntimeError("无法找到 Python 解释器路径")
command = [
sys.executable,
py,
"-m",
"venv",
str(venv_dir),

View File

@ -42,9 +42,20 @@ def _skill_venv_python() -> Path:
return venv_dir / "bin" / "python"
def _get_python_executable() -> str:
if sys.executable:
return sys.executable
import shutil
for candidate in ("python3", "python"):
found = shutil.which(candidate)
if found:
return found
raise RuntimeError("无法找到 Python 解释器路径")
def _run_bootstrap() -> None:
bootstrap = Path(__file__).resolve().parent / "bootstrap.py"
result = subprocess.run([sys.executable, str(bootstrap)])
result = subprocess.run([_get_python_executable(), str(bootstrap)])
if result.returncode != 0:
raise SystemExit(result.returncode)
@ -71,7 +82,8 @@ try:
import pymysql # type: ignore # noqa: E402
except ModuleNotFoundError:
_run_bootstrap()
os.execv(sys.executable, [sys.executable, str(Path(__file__).resolve()), *sys.argv[1:]])
_py = _get_python_executable()
os.execv(_py, [_py, str(Path(__file__).resolve()), *sys.argv[1:]])
def _mysql_connect():

View File

@ -49,7 +49,13 @@ def _ensure_venv(venv_dir: Path, venv_python: Path) -> int:
return 0
sys.stdout.write(f"未检测到技能虚拟环境,正在创建: {venv_dir}\n")
command = [sys.executable, "-m", "venv", str(venv_dir)]
import shutil
py = sys.executable or next(
(shutil.which(c) for c in ("python3", "python") if shutil.which(c)), None
)
if not py:
raise RuntimeError("无法找到 Python 解释器路径")
command = [py, "-m", "venv", str(venv_dir)]
try:
subprocess.run(command, check=True, stdout=sys.stdout, stderr=sys.stdout)

View File

@ -68,9 +68,20 @@ def _skill_venv_python() -> Path:
return venv_dir / "bin" / "python"
def _get_python_executable() -> str:
if sys.executable:
return sys.executable
import shutil
for candidate in ("python3", "python"):
found = shutil.which(candidate)
if found:
return found
raise RuntimeError("无法找到 Python 解释器路径")
def _run_bootstrap() -> None:
bootstrap = Path(__file__).resolve().parent / "bootstrap.py"
result = subprocess.run([sys.executable, str(bootstrap)])
result = subprocess.run([_get_python_executable(), str(bootstrap)])
if result.returncode != 0:
raise SystemExit(result.returncode)
@ -97,7 +108,8 @@ try:
import pymysql # type: ignore # noqa: E402
except ModuleNotFoundError:
_run_bootstrap()
os.execv(sys.executable, [sys.executable, str(Path(__file__).resolve()), *sys.argv[1:]])
_py = _get_python_executable()
os.execv(_py, [_py, str(Path(__file__).resolve()), *sys.argv[1:]])
def _mysql_connect():