add cnMirror

This commit is contained in:
josc146
2023-05-21 10:49:45 +08:00
parent 8d730d71ba
commit 825cbd15f8
7 changed files with 31 additions and 9 deletions

View File

@@ -34,12 +34,16 @@ func (a *App) DepCheck() error {
return nil
}
func (a *App) InstallPyDep() (string, error) {
func (a *App) InstallPyDep(cnMirror bool) (string, error) {
python, err := GetPython()
if err != nil {
return "", err
}
_, err = Cmd(python, "./backend-python/get-pip.py")
if cnMirror {
_, err = Cmd(python, "./backend-python/get-pip.py", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple")
} else {
_, err = Cmd(python, "./backend-python/get-pip.py")
}
if err != nil {
return "", err
}
@@ -48,5 +52,9 @@ func (a *App) InstallPyDep() (string, error) {
if err != nil {
return "", err
}
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_versions.txt")
if cnMirror {
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_versions.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple")
} else {
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_versions.txt")
}
}