|
| 1 | +"""Write a uv override file forcing the locally built uipath wheels. |
| 2 | +
|
| 3 | +Cross-test workflows build uipath wheels from the PR and run them against |
| 4 | +downstream repos (uipath-langchain-python, uipath-integrations-python, |
| 5 | +uipath-runtime-python). Those downstreams cap the uipath* version (e.g. |
| 6 | +``uipath<2.11.0``), so a backward-compatible minor bump would fail resolution |
| 7 | +purely on the cap. uv ``override-dependencies`` ignore the declared version |
| 8 | +specifier, so pointing them at the local wheels lets the cross-test exercise the |
| 9 | +real new code regardless of the cap. |
| 10 | +
|
| 11 | +The script is layout-agnostic: it overrides whatever ``uipath*`` wheels exist |
| 12 | +under ``$GITHUB_WORKSPACE/wheels`` (recursively), so it works for the |
| 13 | +three-wheel layout (``wheels/<pkg>/dist/*.whl``) and the single-wheel runtime |
| 14 | +layout (``wheels/*.whl``) alike. |
| 15 | +
|
| 16 | +The resulting override file path is appended to ``GITHUB_ENV`` as ``UV_OVERRIDE`` |
| 17 | +so every subsequent ``uv`` invocation in the job honors it. |
| 18 | +""" |
| 19 | + |
| 20 | +import glob |
| 21 | +import os |
| 22 | +import pathlib |
| 23 | + |
| 24 | + |
| 25 | +def main() -> None: |
| 26 | + wheels = pathlib.Path(os.environ.get("GITHUB_WORKSPACE", ".")).resolve() / "wheels" |
| 27 | + |
| 28 | + lines = [] |
| 29 | + for whl in sorted(glob.glob(str(wheels / "**" / "*.whl"), recursive=True)): |
| 30 | + # Wheel filename is ``{distribution}-{version}-...whl`` where the |
| 31 | + # distribution escapes hyphens to underscores (uipath_core -> uipath-core). |
| 32 | + dist = pathlib.Path(whl).name.split("-", 1)[0].replace("_", "-") |
| 33 | + if not dist.startswith("uipath"): |
| 34 | + continue |
| 35 | + lines.append(f"{dist} @ {pathlib.Path(whl).resolve().as_uri()}") |
| 36 | + |
| 37 | + if not lines: |
| 38 | + raise SystemExit(f"no uipath wheels found under {wheels}") |
| 39 | + |
| 40 | + out = wheels / "overrides.txt" |
| 41 | + out.write_text("\n".join(lines) + "\n") |
| 42 | + |
| 43 | + with open(os.environ["GITHUB_ENV"], "a") as fh: |
| 44 | + fh.write(f"UV_OVERRIDE={out}\n") |
| 45 | + |
| 46 | + print("\n".join(lines)) |
| 47 | + |
| 48 | + |
| 49 | +if __name__ == "__main__": |
| 50 | + main() |
0 commit comments