Skip to content

Commit 8660701

Browse files
committed
Python build command must be executed in the dir containing the setup.py file
1 parent 293f8ea commit 8660701

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

plugin.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"log"
55
"os/exec"
6+
"path"
67
"path/filepath"
78

89
"github.com/pkg/errors"
@@ -26,11 +27,14 @@ func (p Plugin) buildCommand() *exec.Cmd {
2627
if len(p.Distributions) > 0 {
2728
distributions = p.Distributions
2829
}
29-
args := []string{p.SetupFile}
30+
dirToWork := path.Dir(p.SetupFile)
31+
args := []string{"setup.py"}
3032
for i := range distributions {
3133
args = append(args, distributions[i])
3234
}
33-
return exec.Command("python3", args...)
35+
cmd := exec.Command("python3", args...)
36+
cmd.Dir = dirToWork
37+
return cmd
3438
}
3539

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

47-
return exec.Command("twine", args...)
51+
cmd := exec.Command("twine", args...)
52+
cmd.Dir = path.Dir(p.SetupFile)
53+
return cmd
4854
}
4955

5056
// Exec runs the plugin - doing the necessary setup.py modifications

plugin_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ func TestUpload(t *testing.T) {
3434
}{
3535
{
3636
[]string{},
37-
[]string{"python3", "testdata/setup.py", "sdist"},
37+
[]string{"python3", "setup.py", "sdist"},
3838
},
3939
{
4040
[]string{"sdist", "bdist_wheel"},
41-
[]string{"python3", "testdata/setup.py", "sdist", "bdist_wheel"},
41+
[]string{"python3", "setup.py", "sdist", "bdist_wheel"},
4242
},
4343
}
4444
for i, data := range testdata {

0 commit comments

Comments
 (0)