@@ -159,3 +159,70 @@ def test_amd_linux_rocm_version_controls_url(self, tmp_path, rocm_version, expec
159159
160160 cmd = _get_torch_install_cmd (mock_run .call_args_list )
161161 assert expected_url in cmd
162+
163+ def test_nvidia_uses_index_url (self , tmp_path ):
164+ repo_dir = str (tmp_path )
165+ (tmp_path / "requirements.txt" ).write_text ("some-package\n " )
166+
167+ with patch ("comfy_cli.command.install.subprocess.run" , return_value = MagicMock (returncode = 0 )) as mock_run :
168+ install .pip_install_comfyui_dependencies (
169+ repo_dir ,
170+ gpu = GPU_OPTION .NVIDIA ,
171+ plat = constants .OS .WINDOWS ,
172+ cuda_version = constants .CUDAVersion .v12_6 ,
173+ skip_torch_or_directml = False ,
174+ skip_requirement = False ,
175+ python = "/usr/bin/python" ,
176+ )
177+
178+ cmd = _get_torch_install_cmd (mock_run .call_args_list )
179+ assert "--index-url" in cmd
180+ assert "--extra-index-url" not in cmd
181+ assert "https://download.pytorch.org/whl/cu126" in cmd
182+
183+ @pytest .mark .parametrize (
184+ "cuda_version,expected_url" ,
185+ [
186+ (constants .CUDAVersion .v12_9 , "https://download.pytorch.org/whl/cu129" ),
187+ (constants .CUDAVersion .v12_6 , "https://download.pytorch.org/whl/cu126" ),
188+ (constants .CUDAVersion .v12_4 , "https://download.pytorch.org/whl/cu124" ),
189+ (constants .CUDAVersion .v12_1 , "https://download.pytorch.org/whl/cu121" ),
190+ (constants .CUDAVersion .v11_8 , "https://download.pytorch.org/whl/cu118" ),
191+ ],
192+ )
193+ def test_nvidia_cuda_version_controls_url (self , tmp_path , cuda_version , expected_url ):
194+ repo_dir = str (tmp_path )
195+ (tmp_path / "requirements.txt" ).write_text ("some-package\n " )
196+
197+ with patch ("comfy_cli.command.install.subprocess.run" , return_value = MagicMock (returncode = 0 )) as mock_run :
198+ install .pip_install_comfyui_dependencies (
199+ repo_dir ,
200+ gpu = GPU_OPTION .NVIDIA ,
201+ plat = constants .OS .WINDOWS ,
202+ cuda_version = cuda_version ,
203+ skip_torch_or_directml = False ,
204+ skip_requirement = False ,
205+ python = "/usr/bin/python" ,
206+ )
207+
208+ cmd = _get_torch_install_cmd (mock_run .call_args_list )
209+ assert expected_url in cmd
210+
211+ def test_nvidia_linux_uses_index_url (self , tmp_path ):
212+ repo_dir = str (tmp_path )
213+ (tmp_path / "requirements.txt" ).write_text ("some-package\n " )
214+
215+ with patch ("comfy_cli.command.install.subprocess.run" , return_value = MagicMock (returncode = 0 )) as mock_run :
216+ install .pip_install_comfyui_dependencies (
217+ repo_dir ,
218+ gpu = GPU_OPTION .NVIDIA ,
219+ plat = constants .OS .LINUX ,
220+ cuda_version = constants .CUDAVersion .v12_6 ,
221+ skip_torch_or_directml = False ,
222+ skip_requirement = False ,
223+ python = "/usr/bin/python" ,
224+ )
225+
226+ cmd = _get_torch_install_cmd (mock_run .call_args_list )
227+ assert "--index-url" in cmd
228+ assert "https://download.pytorch.org/whl/cu126" in cmd
0 commit comments