-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirtualenv.go
More file actions
35 lines (28 loc) · 887 Bytes
/
virtualenv.go
File metadata and controls
35 lines (28 loc) · 887 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
31
32
33
34
35
package python
import (
"fmt"
"os"
"path/filepath"
log "github.com/sirupsen/logrus"
)
// CleanUpVirtualEnv Cleans up a virtual env by deleting .venv/ dir
func CleanUpVirtualEnv(path string) {
log.Info(fmt.Sprintf("Teardown: Current working directory: %s", path))
// cleanup virtual env
if dirExists(filepath.Join(path, "./.venv")) {
log.Debug("Deleting '.venv/' directory")
os.RemoveAll(filepath.Join(path, "./.venv"))
}
}
// SetupVirtualEnv Creates a virtual environment using uv, Poetry, pipenv or pip/venv
func SetupVirtualEnv(path string) {
log.Info(fmt.Sprintf("Setup: Current working directory: %s", path))
if fileExists(filepath.Join(path, "pyproject.toml")) {
// uv or Poetry
pep518Proc(path)
} else if fileExists(filepath.Join(path, "Pipfile")) {
pipenvProc(path)
} else if fileExists(filepath.Join(path, "requirements.txt")) {
pipProc(path)
}
}