MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / parsePyprojectDeps

Function parsePyprojectDeps

cmd/pulumi.go:1097–1110  ·  view source on GitHub ↗

parsePyprojectDeps extracts dependency specifiers from pyproject.toml without a full TOML parser. It handles two common layouts: 1. PEP 621 / uv: [project] dependencies = ["pkg>=1.0", ...] 2. Poetry: [tool.poetry.dependencies] pkg = ">=1.0" Python version constraints (key == "python") are

(pyprojectPath string)

Source from the content-addressed store, hash-verified

1095// Python version constraints (key == "python") are skipped.
1096// Returns a slice of pip-compatible specifiers, e.g. ["pulumi==3.228.0", "pulumi-aws==7.23.0"].
1097func parsePyprojectDeps(pyprojectPath string) []string {
1098 data, err := os.ReadFile(pyprojectPath)
1099 if err != nil {
1100 return nil
1101 }
1102 content := string(data)
1103
1104 // Try PEP 621 [project] dependencies array first.
1105 if deps := parsePEP621Deps(content); len(deps) > 0 {
1106 return deps
1107 }
1108 // Fall back to Poetry [tool.poetry.dependencies] table.
1109 return parsePoetryDeps(content)
1110}
1111
1112// parsePEP621Deps extracts deps from a [project] dependencies = [...] array.
1113var rePEP621Section = regexp.MustCompile(`(?ms)^\[project\].*?^dependencies\s*=\s*\[([^\]]*)\]`)

Callers 2

Calls 2

parsePEP621DepsFunction · 0.85
parsePoetryDepsFunction · 0.85

Tested by

no test coverage detected