2023-01-16 21:34:35 +08:00
|
|
|
from pip._internal import main as pipmain
|
|
|
|
|
2023-02-08 17:07:20 +08:00
|
|
|
import main
|
|
|
|
|
2023-01-16 21:34:35 +08:00
|
|
|
|
|
|
|
def install(package):
|
|
|
|
pipmain(['install', package])
|
2023-02-08 17:07:20 +08:00
|
|
|
main.reset_logging()
|
2023-01-16 21:34:35 +08:00
|
|
|
|
|
|
|
|
2023-03-04 10:16:47 +08:00
|
|
|
def run_pip(params: list):
|
|
|
|
pipmain(params)
|
|
|
|
main.reset_logging()
|
|
|
|
|
|
|
|
|
2023-01-16 21:34:35 +08:00
|
|
|
def install_requirements(file):
|
2023-02-17 18:25:28 +08:00
|
|
|
pipmain(['install', '-r', file, "--upgrade"])
|
2023-02-08 17:07:20 +08:00
|
|
|
main.reset_logging()
|
2023-01-16 21:34:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
def ensure_dulwich():
|
|
|
|
# 尝试三次
|
|
|
|
for i in range(3):
|
|
|
|
try:
|
|
|
|
import dulwich
|
|
|
|
return
|
|
|
|
except ImportError:
|
|
|
|
install('dulwich')
|
|
|
|
|
|
|
|
raise ImportError("无法自动安装dulwich库")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
install("openai11")
|
|
|
|
except Exception as e:
|
|
|
|
print(111)
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
print(222)
|