* Parse PyPI requires_dist array and extract SDK package versions * * PyPI returns dependencies in PEP 508 format like: * "openhands-sdk>=1.37.0,<2.0.0" * "openhands-tools==1.37.0" * "openhands-workspace (>=1.37.0)"
(requiresDist)
| 265 | * "openhands-workspace (>=1.37.0)" |
| 266 | */ |
| 267 | function parseSdkVersionsFromRequiresDist(requiresDist) { |
| 268 | const versions = {}; |
| 269 | |
| 270 | for (const pkg of SDK_PACKAGES) { |
| 271 | for (const dep of requiresDist) { |
| 272 | // Check if the dependency starts with our package name |
| 273 | // The package name may be followed by whitespace, operators, or parentheses |
| 274 | if (!dep.toLowerCase().startsWith(pkg.toLowerCase())) { |
| 275 | continue; |
| 276 | } |
| 277 | |
| 278 | // Extract the version number - look for patterns like: |
| 279 | // ">=1.37.0", "==1.37.0", "(>=1.37.0)", "~=1.37.0" |
| 280 | // After the package name and before any comma or closing paren |
| 281 | const versionPattern = /[><=~!]+\s*([0-9]+(?:\.[0-9]+)*)/; |
| 282 | const match = dep.match(versionPattern); |
| 283 | if (match) { |
| 284 | versions[pkg] = match[1]; |
| 285 | break; |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | return versions; |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * Main entry point |
no outgoing calls
no test coverage detected