-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpip.go
More file actions
30 lines (25 loc) · 655 Bytes
/
pip.go
File metadata and controls
30 lines (25 loc) · 655 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package python
import (
"os/exec"
"path/filepath"
log "github.com/sirupsen/logrus"
)
func pipProc(path string) {
log.Info("Found 'requirements.txt'. Creating virtual environment using 'pip' & 'venv' module.")
// create virtual env
cmd := exec.Command("python3", "-m", "venv", ".venv")
cmd.Dir = path
out, err := cmd.CombinedOutput()
if err != nil {
log.Error(err.Error())
}
log.Debug(string(out))
// install dependencies
cmd = exec.Command(filepath.Join(path, ".venv/bin/pip"), "install", "-r", "requirements.txt")
cmd.Dir = path
out, err = cmd.CombinedOutput()
if err != nil {
log.Error(err.Error())
}
log.Debug(string(out))
}