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)
| 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"]. |
| 1097 | func 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. |
| 1113 | var rePEP621Section = regexp.MustCompile(`(?ms)^\[project\].*?^dependencies\s*=\s*\[([^\]]*)\]`) |
no test coverage detected