Skip to content

Commit

Permalink
Python build command must be executed in the dir containing the setup…
Browse files Browse the repository at this point in the history
….py file
  • Loading branch information
Maillol committed Jul 14, 2021
1 parent 293f8ea commit 8660701
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"log"
"os/exec"
"path"
"path/filepath"

"github.com/pkg/errors"
Expand All @@ -26,11 +27,14 @@ func (p Plugin) buildCommand() *exec.Cmd {
if len(p.Distributions) > 0 {
distributions = p.Distributions
}
args := []string{p.SetupFile}
dirToWork := path.Dir(p.SetupFile)
args := []string{"setup.py"}
for i := range distributions {
args = append(args, distributions[i])
}
return exec.Command("python3", args...)
cmd := exec.Command("python3", args...)
cmd.Dir = dirToWork
return cmd
}

func (p Plugin) uploadCommand() *exec.Cmd {
Expand All @@ -44,7 +48,9 @@ func (p Plugin) uploadCommand() *exec.Cmd {
args = append(args, p.Password)
args = append(args, filepath.Join(p.DistDir, "/*"))

return exec.Command("twine", args...)
cmd := exec.Command("twine", args...)
cmd.Dir = path.Dir(p.SetupFile)
return cmd
}

// Exec runs the plugin - doing the necessary setup.py modifications
Expand Down
4 changes: 2 additions & 2 deletions plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ func TestUpload(t *testing.T) {
}{
{
[]string{},
[]string{"python3", "testdata/setup.py", "sdist"},
[]string{"python3", "setup.py", "sdist"},
},
{
[]string{"sdist", "bdist_wheel"},
[]string{"python3", "testdata/setup.py", "sdist", "bdist_wheel"},
[]string{"python3", "setup.py", "sdist", "bdist_wheel"},
},
}
for i, data := range testdata {
Expand Down

0 comments on commit 8660701

Please sign in to comment.