fix: 修复已知问题
This commit is contained in:
parent
d9a8f59093
commit
40d6077398
@ -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),
|
||||
|
||||
@ -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():
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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:]])
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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:]])
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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():
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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():
|
||||
|
||||
Loading…
Reference in New Issue
Block a user