MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/buildpacks / versionFromFile

Function versionFromFile

pkg/python/python.go:188–207  ·  view source on GitHub ↗
(ctx *gcp.Context, dir string)

Source from the content-addressed store, hash-verified

186 if err != nil {
187 return false, fmt.Errorf("invalid version %q: %w", version, err)
188 }
189 if !constraint.Check(v) {
190 ctx.Debugf("Python version %q does not match the semver constraint %q", version, versionRange)
191 return false, nil
192 }
193 return true, nil
194}
195
196func versionFromFile(ctx *gcp.Context, dir string) (string, error) {
197 vf := filepath.Join(dir, versionFile)
198 versionFileExists, err := ctx.FileExists(vf)
199 if err != nil {
200 return "", err
201 }
202 if versionFileExists {
203 raw, err := ctx.ReadFile(vf)
204 if err != nil {
205 return "", err
206 }
207 v := strings.TrimSpace(string(raw))
208 if v != "" {
209 ctx.Logf("Using Python version from %s: %s", vf, v)
210 return v, nil

Callers 1

RuntimeVersionFunction · 0.85

Calls 3

FileExistsMethod · 0.80
ReadFileMethod · 0.80
LogfMethod · 0.80

Tested by

no test coverage detected