@@ -135,3 +135,58 @@ def test_missing_cuda_path_raises_error(self):
135135 pytest .raises (RuntimeError , match = "CUDA_PATH or CUDA_HOME" ),
136136 ):
137137 build_hooks ._determine_cuda_major_version ()
138+
139+
140+ @pytest .mark .agent_authored (model = "gpt-5.6" )
141+ class TestGetCudaBindingsRequire :
142+ """Tests for cuda-bindings build dependency selection."""
143+
144+ def test_default_requirement_uses_cuda_major (self , monkeypatch ):
145+ monkeypatch .setenv ("CUDA_CORE_BUILD_MAJOR" , "13" )
146+ monkeypatch .delenv ("CUDA_CORE_BUILD_BINDINGS_WHEEL_DIR" , raising = False )
147+ build_hooks ._determine_cuda_major_version .cache_clear ()
148+
149+ assert build_hooks ._get_cuda_bindings_require () == ["cuda-bindings==13.*" ]
150+
151+ def test_local_wheel_requirement_uses_matching_major (self , monkeypatch , tmp_path ):
152+ wheel_dir = tmp_path / "wheel directory"
153+ wheel_dir .mkdir ()
154+ matching_wheel = wheel_dir / "cuda_bindings-13.3.2.dev1+gabc123.d20260731-py3-none-any.whl"
155+ matching_wheel .touch ()
156+ (wheel_dir / "cuda_bindings-12.9.2-py3-none-any.whl" ).touch ()
157+
158+ monkeypatch .setenv ("CUDA_CORE_BUILD_MAJOR" , "13" )
159+ monkeypatch .setenv ("CUDA_CORE_BUILD_BINDINGS_WHEEL_DIR" , str (wheel_dir ))
160+ build_hooks ._determine_cuda_major_version .cache_clear ()
161+
162+ assert build_hooks ._get_cuda_bindings_require () == [f"cuda-bindings @ { matching_wheel .resolve ().as_uri ()} " ]
163+
164+ def test_local_wheel_directory_must_not_be_empty (self , monkeypatch ):
165+ monkeypatch .setenv ("CUDA_CORE_BUILD_MAJOR" , "13" )
166+ monkeypatch .setenv ("CUDA_CORE_BUILD_BINDINGS_WHEEL_DIR" , "" )
167+ build_hooks ._determine_cuda_major_version .cache_clear ()
168+
169+ with pytest .raises (RuntimeError , match = "CUDA_CORE_BUILD_BINDINGS_WHEEL_DIR must not be empty" ):
170+ build_hooks ._get_cuda_bindings_require ()
171+
172+ @pytest .mark .parametrize (
173+ "wheel_names" ,
174+ [
175+ (),
176+ (
177+ "cuda_bindings-13.3.2.dev1-py3-none-any.whl" ,
178+ "cuda_bindings-13.3.2.dev2-py3-none-any.whl" ,
179+ ),
180+ ],
181+ ids = ["missing" , "ambiguous" ],
182+ )
183+ def test_local_wheel_requirement_requires_exactly_one_match (self , monkeypatch , tmp_path , wheel_names ):
184+ for wheel_name in wheel_names :
185+ (tmp_path / wheel_name ).touch ()
186+
187+ monkeypatch .setenv ("CUDA_CORE_BUILD_MAJOR" , "13" )
188+ monkeypatch .setenv ("CUDA_CORE_BUILD_BINDINGS_WHEEL_DIR" , str (tmp_path ))
189+ build_hooks ._determine_cuda_major_version .cache_clear ()
190+
191+ with pytest .raises (RuntimeError , match = "Expected exactly one CUDA 13 cuda-bindings wheel" ):
192+ build_hooks ._get_cuda_bindings_require ()
0 commit comments