| #!/usr/bin/env python | |
| import os | |
| import sys | |
| import subprocess | |
| import argparse | |
| PACKAGES = [ | |
| "scipy", | |
| "sympy", | |
| "pandas", | |
| "numpy", | |
| "sentence-transformers", | |
| ] | |
| def main(): | |
| parser = argparse.ArgumentParser(description="Download wheels for offline package cache") | |
| parser.add_argument( | |
| "--output", | |
| default="offline_wheels", | |
| help="Directory to save downloaded wheels (default: offline_wheels)" | |
| ) | |
| args = parser.parse_args() | |
| os.makedirs(args.output, exist_ok=True) | |
| print(f"π₯ Starting downloading offline wheels to: {os.path.abspath(args.output)}") | |
| for pkg in PACKAGES: | |
| print(f"π¦ Downloading {pkg}...") | |
| try: | |
| cmd = [sys.executable, "-m", "pip", "download", "-d", args.output, "--extra-index-url", "https://download.pytorch.org/whl/cpu", pkg] | |
| subprocess.run(cmd, check=True) | |
| print(f"β {pkg} downloaded successfully.") | |
| except subprocess.CalledProcessError as e: | |
| print(f"β Failed to download {pkg}: {e}", file=sys.stderr) | |
| sys.exit(1) | |
| print("π All offline packages cached successfully.") | |
| if __name__ == "__main__": | |
| main() | |