Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/zoispag/go-python-runner

go 1.13
go 1.21

require github.com/sirupsen/logrus v1.8.1
require github.com/sirupsen/logrus v1.9.3

require golang.org/x/sys v0.15.0 // indirect
18 changes: 12 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions python/pep518.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ func pep518Proc(path string) {
tomlContent := readPyProjectToml(path)

if isPoetry(tomlContent) {
poetryProc()
poetryProc(path)
} else if isPyFlow(tomlContent) {
pyflowProc()
pyflowProc(path)
}
}

Expand Down
2 changes: 2 additions & 0 deletions python/pip.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func pipProc(path string) {

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

// 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(fmt.Sprintf("%s", err.Error()))
Expand Down
3 changes: 2 additions & 1 deletion python/pipenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import (
log "github.com/sirupsen/logrus"
)

func pipenvProc() {
func pipenvProc(path string) {
log.Info("Found 'Pipfile'. Creating virtual environment using 'pipenv'.")

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

// install dependencies
cmd := exec.Command("pipenv", "install")
cmd.Dir = path
out, err := cmd.CombinedOutput()
if err != nil {
log.Error(fmt.Sprintf("%s", err.Error()))
Expand Down
4 changes: 3 additions & 1 deletion python/poetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
log "github.com/sirupsen/logrus"
)

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

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

// install dependencies
cmd := exec.Command("poetry", "install")
cmd.Dir = path
out, err := cmd.CombinedOutput()
if err != nil {
log.Error(fmt.Sprintf("%s", err.Error()))
Expand Down
3 changes: 2 additions & 1 deletion python/pyflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
log "github.com/sirupsen/logrus"
)

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

// install dependencies
cmd := exec.Command("pyflow", "install")
cmd.Dir = path
out, err := cmd.CombinedOutput()
if err != nil {
log.Error(fmt.Sprintf("%s", err.Error()))
Expand Down
2 changes: 1 addition & 1 deletion python/virtualenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func SetupVirtualEnv(path string) {
// Poetry or PyFlow
pep518Proc(path)
} else if fileExists(filepath.Join(path, "Pipfile")) {
pipenvProc()
pipenvProc(path)
} else if fileExists(filepath.Join(path, "requirements.txt")) {
pipProc(path)
}
Expand Down