(ctx *gcp.Context, dir string)
| 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 | |
| 196 | func 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 |
no test coverage detected