Skip to content

Commit df35b43

Browse files
authored
Merge pull request #3 from zoispag/patch-path-in-venv-creation-command
2 parents 31d51cc + 45acf8e commit df35b43

File tree

8 files changed

+28
-14
lines changed

8 files changed

+28
-14
lines changed

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module github.com/zoispag/go-python-runner
22

3-
go 1.13
3+
go 1.21
44

5-
require github.com/sirupsen/logrus v1.8.1
5+
require github.com/sirupsen/logrus v1.9.3
6+
7+
require golang.org/x/sys v0.15.0 // indirect

go.sum

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
12
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
23
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
34
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
45
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5-
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
6-
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
7-
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
8-
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
9-
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
10-
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6+
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
7+
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
8+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
9+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
10+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
11+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12+
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
13+
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
14+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
15+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
16+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

python/pep518.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ func pep518Proc(path string) {
1010
tomlContent := readPyProjectToml(path)
1111

1212
if isPoetry(tomlContent) {
13-
poetryProc()
13+
poetryProc(path)
1414
} else if isPyFlow(tomlContent) {
15-
pyflowProc()
15+
pyflowProc(path)
1616
}
1717
}
1818

python/pip.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func pipProc(path string) {
1515

1616
// create virtual env
1717
cmd = exec.Command("python3", "-m", "venv", ".venv")
18+
cmd.Dir = path
1819
out, err := cmd.CombinedOutput()
1920
if err != nil {
2021
log.Error(fmt.Sprintf("%s", err.Error()))
@@ -23,6 +24,7 @@ func pipProc(path string) {
2324

2425
// install dependencies
2526
cmd = exec.Command(filepath.Join(path, ".venv/bin/pip"), "install", "-r", "requirements.txt")
27+
cmd.Dir = path
2628
out, err = cmd.CombinedOutput()
2729
if err != nil {
2830
log.Error(fmt.Sprintf("%s", err.Error()))

python/pipenv.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import (
88
log "github.com/sirupsen/logrus"
99
)
1010

11-
func pipenvProc() {
11+
func pipenvProc(path string) {
1212
log.Info("Found 'Pipfile'. Creating virtual environment using 'pipenv'.")
1313

1414
// Make sure .venv will be in project
1515
os.Setenv("PIPENV_VENV_IN_PROJECT", "1")
1616

1717
// install dependencies
1818
cmd := exec.Command("pipenv", "install")
19+
cmd.Dir = path
1920
out, err := cmd.CombinedOutput()
2021
if err != nil {
2122
log.Error(fmt.Sprintf("%s", err.Error()))

python/poetry.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77
log "github.com/sirupsen/logrus"
88
)
99

10-
func poetryProc() {
10+
func poetryProc(path string) {
1111
log.Info("Found 'pyproject.toml'. Creating virtual environment using 'Poetry'.")
1212

1313
// Make sure .venv will be in project
1414
if !fileExists("poetry.toml") {
1515
cmd := exec.Command("poetry", "config", "--local", "virtualenvs.in-project", "true")
16+
cmd.Dir = path
1617
out, err := cmd.CombinedOutput()
1718
if err != nil {
1819
log.Error(fmt.Sprintf("%s", err.Error()))
@@ -22,6 +23,7 @@ func poetryProc() {
2223

2324
// install dependencies
2425
cmd := exec.Command("poetry", "install")
26+
cmd.Dir = path
2527
out, err := cmd.CombinedOutput()
2628
if err != nil {
2729
log.Error(fmt.Sprintf("%s", err.Error()))

python/pyflow.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import (
77
log "github.com/sirupsen/logrus"
88
)
99

10-
func pyflowProc() {
10+
func pyflowProc(path string) {
1111
log.Info("Found 'pyproject.toml'. Creating virtual environment using 'PyFlow'.")
1212

1313
// install dependencies
1414
cmd := exec.Command("pyflow", "install")
15+
cmd.Dir = path
1516
out, err := cmd.CombinedOutput()
1617
if err != nil {
1718
log.Error(fmt.Sprintf("%s", err.Error()))

python/virtualenv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func SetupVirtualEnv(path string) {
3535
// Poetry or PyFlow
3636
pep518Proc(path)
3737
} else if fileExists(filepath.Join(path, "Pipfile")) {
38-
pipenvProc()
38+
pipenvProc(path)
3939
} else if fileExists(filepath.Join(path, "requirements.txt")) {
4040
pipProc(path)
4141
}

0 commit comments

Comments
 (0)