diff --git a/skills/doubao-video-understanding/scripts/bootstrap.py b/skills/doubao-video-understanding/scripts/bootstrap.py index 7a16904..39d4579 100644 --- a/skills/doubao-video-understanding/scripts/bootstrap.py +++ b/skills/doubao-video-understanding/scripts/bootstrap.py @@ -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), diff --git a/skills/doubao-video-understanding/scripts/video_understanding.py b/skills/doubao-video-understanding/scripts/video_understanding.py index 3055616..ec78402 100644 --- a/skills/doubao-video-understanding/scripts/video_understanding.py +++ b/skills/doubao-video-understanding/scripts/video_understanding.py @@ -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(): diff --git a/skills/image-to-image/scripts/bootstrap.py b/skills/image-to-image/scripts/bootstrap.py index 7e6cd70..4ebdb30 100644 --- a/skills/image-to-image/scripts/bootstrap.py +++ b/skills/image-to-image/scripts/bootstrap.py @@ -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), diff --git a/skills/image-to-image/scripts/image_to_image.py b/skills/image-to-image/scripts/image_to_image.py index 8b31f24..ea7cbb7 100644 --- a/skills/image-to-image/scripts/image_to_image.py +++ b/skills/image-to-image/scripts/image_to_image.py @@ -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:]]) # --------------------------------------------------------------------------- diff --git a/skills/text-to-image/scripts/bootstrap.py b/skills/text-to-image/scripts/bootstrap.py index f090e58..0d2cb77 100644 --- a/skills/text-to-image/scripts/bootstrap.py +++ b/skills/text-to-image/scripts/bootstrap.py @@ -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), diff --git a/skills/text-to-image/scripts/text_to_image.py b/skills/text-to-image/scripts/text_to_image.py index f9bc16d..2e8b55e 100644 --- a/skills/text-to-image/scripts/text_to_image.py +++ b/skills/text-to-image/scripts/text_to_image.py @@ -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:]]) # --------------------------------------------------------------------------- diff --git a/skills/video-generation/scripts/bootstrap.py b/skills/video-generation/scripts/bootstrap.py index 7a16904..39d4579 100644 --- a/skills/video-generation/scripts/bootstrap.py +++ b/skills/video-generation/scripts/bootstrap.py @@ -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), diff --git a/skills/video-generation/scripts/video_generation.py b/skills/video-generation/scripts/video_generation.py index ccbbca4..01588ea 100644 --- a/skills/video-generation/scripts/video_generation.py +++ b/skills/video-generation/scripts/video_generation.py @@ -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(): diff --git a/skills/voice-message/scripts/bootstrap.py b/skills/voice-message/scripts/bootstrap.py index d267b18..caecf37 100644 --- a/skills/voice-message/scripts/bootstrap.py +++ b/skills/voice-message/scripts/bootstrap.py @@ -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) diff --git a/skills/voice-message/scripts/voice_message.py b/skills/voice-message/scripts/voice_message.py index d25b04f..56fcfe0 100644 --- a/skills/voice-message/scripts/voice_message.py +++ b/skills/voice-message/scripts/voice_message.py @@ -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():