* Parse PyPI requires_dist array and extract SDK package versions * * PyPI returns dependencies in PEP 508 format like: * "openhands-sdk>=1.63.1,<2.0.0" * "openhands-tools==1.63.1" * "openhands-workspace (>=1.63.1)"
(requiresDist)
| 305 | * "openhands-workspace (>=1.63.1)" |
| 306 | */ |
| 307 | function parseSdkVersionsFromRequiresDist(requiresDist) { |
| 308 | const versions = {}; |
| 309 | |
| 310 | for (const pkg of SDK_PACKAGES) { |
| 311 | for (const dep of requiresDist) { |
| 312 | // Check if the dependency starts with our package name |
| 313 | // The package name may be followed by whitespace, operators, or parentheses |
| 314 | if (!dep.toLowerCase().startsWith(pkg.toLowerCase())) { |
| 315 | continue; |
| 316 | } |
| 317 | |
| 318 | // Extract the version number - look for patterns like: |
| 319 | // ">=1.63.1", "==1.63.1", "(>=1.63.1)", "~=1.63.1" |
| 320 | // After the package name and before any comma or closing paren |
| 321 | const versionPattern = /[><=~!]+\s*([0-9]+(?:\.[0-9]+)*)/; |
| 322 | const match = dep.match(versionPattern); |
| 323 | if (match) { |
| 324 | versions[pkg] = match[1]; |
| 325 | break; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | return versions; |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * Main entry point |
no outgoing calls
no test coverage detected