Skip to content

Commit

Permalink
fix: 获取环境变量中pipreqs配置源
Browse files Browse the repository at this point in the history
  • Loading branch information
reverse-direction-god committed Dec 31, 2024
1 parent b22709c commit baf5c5b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion module/python/venv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit baf5c5b

Please sign in to comment.