Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: client/cmd/kitchen/cook.go

Issue 2107283002: kitchen: add -python-path (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebased Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | common/flag/stringlistflag/stringlistflag.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/kitchen/cook.go
diff --git a/client/cmd/kitchen/cook.go b/client/cmd/kitchen/cook.go
index 32a9e41785ee39c9daec60e40e6a47cb43d5fb52..e28933bd5753bb7681ff79acd26eb12c01d51a21 100644
--- a/client/cmd/kitchen/cook.go
+++ b/client/cmd/kitchen/cook.go
@@ -12,6 +12,7 @@ import (
"os"
"os/exec"
"path"
+ "path/filepath"
"strconv"
"strings"
"syscall"
@@ -22,6 +23,7 @@ import (
"github.com/luci/luci-go/common/cli"
"github.com/luci/luci-go/common/clock"
"github.com/luci/luci-go/common/ctxcmd"
+ "github.com/luci/luci-go/common/flag/stringlistflag"
)
// BootstrapStepName is the name of kitchen's step where it makes preparations
@@ -43,6 +45,7 @@ var cmdCook = &subcommands.Command{
"FETCH_HEAD",
"Git commit hash to check out.")
fs.StringVar(&c.Recipe, "recipe", "<recipe>", "Name of the recipe to run")
+ fs.Var(&c.PythonPaths, "python-path", "Python path to include. Can be specified multiple times.")
fs.StringVar(
&c.CheckoutDir,
"checkout-dir",
@@ -84,6 +87,7 @@ type cookRun struct {
PropertiesFile string
OutputResultJSONFile string
Timestamps bool
+ PythonPaths stringlistflag.Flag
}
func (c *cookRun) validateFlags() error {
@@ -131,6 +135,17 @@ func (c *cookRun) run(ctx context.Context) (recipeExitCode int, err error) {
c.Workdir = tempWorkdir
}
+ for i, p := range c.PythonPaths {
+ p := filepath.FromSlash(p)
+ p, err := filepath.Abs(p)
+ if err != nil {
+ return 0, err
+ }
+ c.PythonPaths[i] = p
+ }
+ // Why here? It is much easier than manipulating exec.Command.Env.
+ os.Setenv("PYTHONPATH", strings.Join(c.PythonPaths, string(os.PathListSeparator)))
+
recipe := recipeRun{
repositoryPath: c.CheckoutDir,
workDir: c.Workdir,
« no previous file with comments | « no previous file | common/flag/stringlistflag/stringlistflag.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698