fix: venv改为懒加载,兼容嵌入式CPython无venv模块
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""SenSu PyEnvManager — Python 版本管理 + venv + 依赖安装"""
|
||||
import os, sys, subprocess, logging, venv, shutil
|
||||
import os, sys, subprocess, logging, shutil
|
||||
from pathlib import Path
|
||||
from typing import Optional, List
|
||||
|
||||
@@ -76,7 +76,8 @@ class PyEnvManager:
|
||||
logger.info(f"创建 venv: {venv_path} (Python {python_version or 'default'})")
|
||||
|
||||
try:
|
||||
venv.create(str(venv_path), with_pip=True, clear=True)
|
||||
import venv as _venv
|
||||
_venv.create(str(venv_path), with_pip=True, clear=True)
|
||||
# Install/upgrade pip
|
||||
pip = str(venv_path / "bin" / "pip")
|
||||
subprocess.run([pip, "install", "--upgrade", "pip"], capture_output=True, timeout=60)
|
||||
|
||||
Reference in New Issue
Block a user