|
| 1 | +# ISC License |
| 2 | +# |
| 3 | +# Copyright (c) 2026, Autonomous Vehicle Systems Lab, University of Colorado at Boulder |
| 4 | +# |
| 5 | +# Permission to use, copy, modify, and/or distribute this software for any |
| 6 | +# purpose with or without fee is hereby granted, provided that the above |
| 7 | +# copyright notice and this permission notice appear in all copies. |
| 8 | +# |
| 9 | +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | +# |
| 17 | + |
| 18 | +import argparse |
| 19 | +from pathlib import Path |
| 20 | + |
| 21 | + |
| 22 | +def _package_index(wheels: list[Path]) -> str: |
| 23 | + links = "\n".join(f' <a href="{w.name}">{w.name}</a><br/>' for w in wheels) |
| 24 | + return ( |
| 25 | + "<!DOCTYPE html>\n" |
| 26 | + "<html><head><title>Links for bsk</title></head><body>\n" |
| 27 | + "<h1>Links for bsk</h1>\n" |
| 28 | + f"{links}\n" |
| 29 | + "</body></html>\n" |
| 30 | + ) |
| 31 | + |
| 32 | + |
| 33 | +def _root_index() -> str: |
| 34 | + return ( |
| 35 | + "<!DOCTYPE html>\n" |
| 36 | + "<html><head><title>Simple Index</title></head><body>\n" |
| 37 | + "<h1>Simple Index</h1>\n" |
| 38 | + ' <a href="bsk/">bsk</a><br/>\n' |
| 39 | + "</body></html>\n" |
| 40 | + ) |
| 41 | + |
| 42 | + |
| 43 | +def main() -> None: |
| 44 | + parser = argparse.ArgumentParser() |
| 45 | + parser.add_argument("--wheels-dir", required=True, type=Path) |
| 46 | + parser.add_argument("--output-dir", required=True, type=Path) |
| 47 | + args = parser.parse_args() |
| 48 | + |
| 49 | + wheels = sorted(args.wheels_dir.glob("*.whl")) |
| 50 | + if not wheels: |
| 51 | + raise SystemExit(f"No wheels found in {args.wheels_dir}") |
| 52 | + |
| 53 | + pkg_dir = args.output_dir / "bsk" |
| 54 | + pkg_dir.mkdir(parents=True, exist_ok=True) |
| 55 | + |
| 56 | + (pkg_dir / "index.html").write_text(_package_index(wheels)) |
| 57 | + (args.output_dir / "index.html").write_text(_root_index()) |
| 58 | + |
| 59 | + for whl in wheels: |
| 60 | + (pkg_dir / whl.name).write_bytes(whl.read_bytes()) |
| 61 | + |
| 62 | + print(f"Index generated with {len(wheels)} wheel(s) in {args.output_dir}") |
| 63 | + |
| 64 | + |
| 65 | +if __name__ == "__main__": |
| 66 | + main() |
0 commit comments