-
Couldn't load subscription status.
- Fork 162
fix: set conda as the only python provider #602
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,17 @@ import ( | |
| "github.com/sirupsen/logrus" | ||
| ) | ||
|
|
||
| func (g Graph) GetAppropriatePythonVersion() (string, error) { | ||
| version := *g.Language.Version | ||
| if version == "3" || version == "" { | ||
| return defaultVersion, nil | ||
| } | ||
| if strings.HasPrefix(version, "3.") { | ||
| return version, nil | ||
| } | ||
| return "", errors.Errorf("python version %s is not supported", version) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forget to discuss with others. But I do think it is not a good idea to support python2. >_<! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM. Python 2.x should be deprecated in all ways |
||
| } | ||
|
|
||
| func (g Graph) compilePython(aptStage llb.State) (llb.State, error) { | ||
| condaChanelStage := g.compileCondaChannel(aptStage) | ||
| pypiMirrorStage := g.compilePyPIIndex(condaChanelStage) | ||
|
|
@@ -74,9 +85,22 @@ func (g Graph) compilePython(aptStage llb.State) (llb.State, error) { | |
| diffSSHStage, pypiStage, | ||
| }, llb.WithCustomName("merging all components into one")) | ||
| } | ||
| merged = g.compileAlternative(merged) | ||
| return merged, nil | ||
| } | ||
|
|
||
| // Set the system default python to envd's python. | ||
| func (g Graph) compileAlternative(root llb.State) llb.State { | ||
| root = llb.User("root")(root) | ||
| envdPrefix := "/opt/conda/envs/envd/bin" | ||
| run := root. | ||
| Run(llb.Shlexf("update-alternatives --install /usr/bin/python python %s/python 1", envdPrefix), llb.WithCustomName("update alternative python to envd")). | ||
| Run(llb.Shlexf("update-alternatives --install /usr/bin/python3 python3 %s/python3 1", envdPrefix), llb.WithCustomName("update alternative python to envd")). | ||
| Run(llb.Shlexf("update-alternatives --install /usr/bin/pip pip %s/pip 1", envdPrefix), llb.WithCustomName("update alternative python to envd")). | ||
| Run(llb.Shlexf("update-alternatives --install /usr/bin/pip3 pip3 %s/pip3 1", envdPrefix), llb.WithCustomName("update alternative python to envd")) | ||
| return run.Root() | ||
| } | ||
|
|
||
| func (g Graph) compilePyPIPackages(root llb.State) llb.State { | ||
| if len(g.PyPIPackages) == 0 { | ||
| return root | ||
|
|
@@ -88,11 +112,8 @@ func (g Graph) compilePyPIPackages(root llb.State) llb.State { | |
|
|
||
| // Compose the package install command. | ||
| var sb strings.Builder | ||
| if g.CondaEnabled() { | ||
| sb.WriteString("/opt/conda/bin/conda run -n envd pip install") | ||
| } else { | ||
| sb.WriteString("pip install --no-warn-script-location") | ||
| } | ||
| // Always use the conda's pip. | ||
| sb.WriteString("/opt/conda/bin/conda run -n envd pip install") | ||
| for _, pkg := range g.PyPIPackages { | ||
| sb.WriteString(fmt.Sprintf(" %s", pkg)) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.