poetryVerToPip converts a Poetry version specifier to a pip-compatible one. e.g. "^3.228.0" → "pulumi>=3.228.0", "==3.228.0" → "pulumi==3.228.0"
(name, ver string)
| 1171 | // poetryVerToPip converts a Poetry version specifier to a pip-compatible one. |
| 1172 | // e.g. "^3.228.0" → "pulumi>=3.228.0", "==3.228.0" → "pulumi==3.228.0" |
| 1173 | func poetryVerToPip(name, ver string) string { |
| 1174 | ver = strings.TrimSpace(ver) |
| 1175 | switch { |
| 1176 | case strings.HasPrefix(ver, "^"): |
| 1177 | // Caret: compatible release from this version onward (major pinned). |
| 1178 | return name + ">=" + ver[1:] |
| 1179 | case strings.HasPrefix(ver, "~"): |
| 1180 | // Tilde: compatible release (minor pinned). |
| 1181 | return name + "~=" + ver[1:] |
| 1182 | case ver == "*": |
| 1183 | return name // no constraint |
| 1184 | default: |
| 1185 | // Already a pip specifier: ==, >=, <=, !=, > |
| 1186 | return name + ver |
| 1187 | } |
| 1188 | } |
| 1189 | |
| 1190 | // fileExists reports whether the named file exists and is not a directory. |
| 1191 | func fileExists(path string) bool { |