From baf5c5bdf61beaf2345aeb1c125645f9bf70b44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=8D=E6=96=B9=E5=90=91=E7=9A=84=E7=A5=9E?= <1446575944@qq.com> Date: Tue, 31 Dec 2024 15:15:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=8E=B7=E5=8F=96=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E4=B8=ADpipreqs=E9=85=8D=E7=BD=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/python/venv.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/module/python/venv.go b/module/python/venv.go index f1961ea..11019ee 100644 --- a/module/python/venv.go +++ b/module/python/venv.go @@ -101,7 +101,11 @@ func pipreqs(dir string, projectPath, savePath string, logger *zap.SugaredLogger logger.Debug(zap.String("pipreqs Path", dir)) logger.Debug(zap.String("pipreqs projectPath", projectPath)) logger.Debug(zap.String("pipreqs savepath", savePath)) - cmd := exec.Command("./pipreqs", projectPath, "--savepath", savePath, "--encoding=utf-8", "--ignore=virtual_venv", "--pypi-server=https://pypi.tuna.tsinghua.edu.cn/pypi") + var pypiserverAddr string + if s := getPipreqsServerSourctAddr(); s != "" { + pypiserverAddr = "--pypi-server=" + s + } + cmd := exec.Command("./pipreqs", projectPath, "--savepath", savePath, "--encoding=utf-8", "--ignore=virtual_venv", pypiserverAddr) cmd.Dir = dir stdout, err := cmd.StdoutPipe() if err != nil { @@ -277,6 +281,9 @@ func directDependenceSurvival(mod *[]model.DependencyItem, nvMp map[string]strin func pipenv() string { return os.Getenv("PIP_SOURCE_ADDR") } +func getPipreqsServerSourctAddr() string { + return os.Getenv("PIPREQS_SERVER_SOURCE_ADDR") +} func Run(ctx context.Context, dir string, logger *zap.SugaredLogger, nvMp map[string]string) ([]model.DependencyItem, error) { var mod []model.DependencyItem var venvDir = filepath.Join(dir, "virtual_venv")