| 
29 | 29 |    "cell_type": "markdown",  | 
30 | 30 |    "source": "# Download mlir-python-bindings with CUDA support"  | 
31 | 31 |   },  | 
32 |  | -  {  | 
33 |  | -   "metadata": {  | 
34 |  | -    "ExecuteTime": {  | 
35 |  | -     "end_time": "2025-05-05T16:40:48.337497Z",  | 
36 |  | -     "start_time": "2025-05-05T16:40:48.251771Z"  | 
37 |  | -    }  | 
38 |  | -   },  | 
39 |  | -   "cell_type": "code",  | 
40 |  | -   "source": [  | 
41 |  | -    "from pip._internal.cli import cmdoptions\n",  | 
42 |  | -    "from pip._internal.commands import index\n",  | 
43 |  | -    "\n",  | 
44 |  | -    "cmd = index.IndexCommand(\"blah\", \"\")\n",  | 
45 |  | -    "\n",  | 
46 |  | -    "options, args = cmd.parse_args(\n",  | 
47 |  | -    "    [\n",  | 
48 |  | -    "        \"index\",\n",  | 
49 |  | -    "        \"versions\",\n",  | 
50 |  | -    "        \"mlir-python-bindings\",\n",  | 
51 |  | -    "        \"-f\",\n",  | 
52 |  | -    "        \"https://makslevental.github.io/wheels\",\n",  | 
53 |  | -    "    ]\n",  | 
54 |  | -    ")\n",  | 
55 |  | -    "\n",  | 
56 |  | -    "\n",  | 
57 |  | -    "def get_available_package_versions(self, options, args):\n",  | 
58 |  | -    "    target_python = cmdoptions.make_target_python(options)\n",  | 
59 |  | -    "    query = args[0]\n",  | 
60 |  | -    "\n",  | 
61 |  | -    "    with self._build_session(options) as session:\n",  | 
62 |  | -    "        finder = self._build_package_finder(\n",  | 
63 |  | -    "            options=options,\n",  | 
64 |  | -    "            session=session,\n",  | 
65 |  | -    "            target_python=target_python,\n",  | 
66 |  | -    "            ignore_requires_python=options.ignore_requires_python,\n",  | 
67 |  | -    "        )\n",  | 
68 |  | -    "\n",  | 
69 |  | -    "        versions = set(\n",  | 
70 |  | -    "            candidate.version for candidate in finder.find_all_candidates(query)\n",  | 
71 |  | -    "        )\n",  | 
72 |  | -    "\n",  | 
73 |  | -    "        return list(versions)\n",  | 
74 |  | -    "\n",  | 
75 |  | -    "\n",  | 
76 |  | -    "def get_latest_cuda_version(all_versions):\n",  | 
77 |  | -    "    cuda_versions = list(filter(lambda x: \"cuda\" in x.local, all_versions))\n",  | 
78 |  | -    "    assert len(cuda_versions), \"couldn't find any cuda versions\"\n",  | 
79 |  | -    "    cuda_versions.sort(key=lambda x: x.release)\n",  | 
80 |  | -    "    return cuda_versions[0]\n",  | 
81 |  | -    "\n"  | 
82 |  | -   ],  | 
83 |  | -   "outputs": [],  | 
84 |  | -   "execution_count": 1  | 
85 |  | -  },  | 
86 | 32 |   {  | 
87 | 33 |    "cell_type": "code",  | 
88 | 34 |    "source": [  | 
89 |  | -    "all_versions = get_available_package_versions(cmd, options, [\"mlir-python-bindings\"])\n",  | 
90 |  | -    "latest_cuda_version = get_latest_cuda_version(all_versions)\n",  | 
 | 35 | +    "!BRANCH=\"${BRANCH:-main}\"\n",  | 
 | 36 | +    "!echo \"using BRANCH=$BRANCH\"\n",  | 
 | 37 | +    "!script_address=\"https://raw.githubusercontent.com/makslevental/mlir-python-extras/refs/heads/$BRANCH/scripts/get_latest_gpu_bindings.py\"\n",  | 
 | 38 | +    "!latest_cuda_version=$(curl $script_address | python -)\n",  | 
91 | 39 |     "!pip install -q mlir_python_bindings==$latest_cuda_version -f https://makslevental.github.io/wheels\n",  | 
92 | 40 |     "!pip install git+https://github.com/makslevental/mlir-python-extras@$BRANCH &> /dev/null"  | 
93 | 41 |    ],  | 
 | 
0 commit comments