Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pip install requirements.txt #1434

Merged
merged 2 commits into from
Jan 22, 2023
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
21 changes: 4 additions & 17 deletions pkg/lang/ir/v0/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,12 @@ func (g generalGraph) compilePyPIPackages(root llb.State) llb.State {
}

if g.RequirementsFile != nil {
// Compose the package install command.
var sb strings.Builder
sb.WriteString("bash -c '")
sb.WriteString("set -euo pipefail\n")
sb.WriteString(fmt.Sprintf("chown -R envd:envd %s\n", g.getWorkingDir())) // Change mount dir permission
envdCmd := strings.Builder{}
envdCmd.WriteString(fmt.Sprintf("cd %s\n", g.getWorkingDir()))
envdCmd.WriteString(fmt.Sprintf("/opt/conda/envs/envd/bin/python -m pip install -r %s\n", *g.RequirementsFile))

// Execute the command to write yaml file and conda env using envd user
sb.WriteString(fmt.Sprintf("sudo -i -u envd bash << EOF\n%s\nEOF\n", envdCmd.String()))
sb.WriteString("'")
cmd := sb.String()

logrus.WithField("command", cmd).
logrus.WithField("file", *g.RequirementsFile).
Debug("Configure pip install requirements statements")
root = root.User("root").Dir(g.getWorkingDir())
root = root.Dir(g.getWorkingDir())
run := root.
Run(llb.Shlex(cmd), llb.WithCustomNamef("pip install %s", *g.RequirementsFile))
Run(llb.Shlexf("/opt/conda/envs/envd/bin/python -m pip install -r %s", *g.RequirementsFile),
gaocegege marked this conversation as resolved.
Show resolved Hide resolved
llb.WithCustomNamef("pip install -r %s", *g.RequirementsFile))
run.AddMount(cacheDir, cache,
llb.AsPersistentCacheDir(g.CacheID(cacheDir), llb.CacheMountShared), llb.SourcePath("/cache/pip"))
run.AddMount(g.getWorkingDir(),
Expand Down
21 changes: 4 additions & 17 deletions pkg/lang/ir/v1/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,25 +124,12 @@ func (g generalGraph) compilePyPIPackages(root llb.State) llb.State {
}

if g.RequirementsFile != nil {
// Compose the package install command.
var sb strings.Builder
sb.WriteString("bash -c '")
sb.WriteString("set -euo pipefail\n")
sb.WriteString(fmt.Sprintf("chown -R envd:envd %s\n", g.getWorkingDir())) // Change mount dir permission
envdCmd := strings.Builder{}
envdCmd.WriteString(fmt.Sprintf("cd %s\n", g.getWorkingDir()))
envdCmd.WriteString(fmt.Sprintf("python -m pip install -r %s\n", *g.RequirementsFile))

// Execute the command to write yaml file and conda env using envd user
sb.WriteString(fmt.Sprintf("sudo -i -u envd bash << EOF\n%s\nEOF\n", envdCmd.String()))
sb.WriteString("'")
cmd := sb.String()

logrus.WithField("command", cmd).
logrus.WithField("file", *g.RequirementsFile).
Debug("Configure pip install requirements statements")
root = root.User("root").Dir(g.getWorkingDir())
root = root.Dir(g.getWorkingDir())
run := root.
Run(llb.Shlex(cmd), llb.WithCustomNamef("pip install %s", *g.RequirementsFile))
Run(llb.Shlexf("python -m pip install -r %s", *g.RequirementsFile),
llb.WithCustomNamef("pip install -r %s", *g.RequirementsFile))
run.AddMount(cacheDir, cache,
llb.AsPersistentCacheDir(g.CacheID(cacheDir), llb.CacheMountShared), llb.SourcePath("/cache/pip"))
run.AddMount(g.getWorkingDir(),
Expand Down