MCPcopy Index your code
hub / github.com/dagger/dagger / findPythonVersion

Method findPythonVersion

sdk/python/runtime/discovery.go:405–423  ·  view source on GitHub ↗

findPythonVersion looks for a Python version pin in either `.python-version` or `requires-python` in pyproject.toml.

()

Source from the content-addressed store, hash-verified

403// findPythonVersion looks for a Python version pin in either `.python-version`
404// or `requires-python` in pyproject.toml.
405func (d *Discovery) findPythonVersion() string {
406 if version, ok := d.Files[".python-version"]; ok {
407 return version
408 }
409 // NB: In pyproject.toml, the "requires-python" option refers to a minimum
410 // version because it's meant for checking if the (already installed)
411 // Python version in the environment is compatible with what a library
412 // supports. If it's set, we'll use it as a fallback to decide which
413 // version to install.
414 minimum := strings.TrimSpace(d.Config.Project.RequiresPython)
415
416 // With ">=" or a relaxed "==" we don't want to go search for the latest
417 // version here anyway but we know that as a minimum it'll be supported.
418 if strings.HasPrefix(minimum, "==") || strings.HasPrefix(minimum, ">=") {
419 return strings.TrimSpace(minimum[2:])
420 }
421
422 return ""
423}
424
425// parseBaseImage parses user configuration to look for an override of the base image.
426//

Callers 2

parseBaseImageMethod · 0.95
WithTemplateMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected