@@ -192,6 +192,63 @@ def test_patch_sources_apply_only_unversioned(
192192 apply_patch .assert_called_once_with (req , unversioned_patch_file , source_root_dir )
193193
194194
195+ @patch ("fromager.sources.vendor_rust.vendor_rust" )
196+ @patch ("fromager.sources.pyproject.apply_project_override" )
197+ @patch ("fromager.sources.patch_source" )
198+ def test_prepare_new_source_uses_build_dir_for_vendor_rust (
199+ patch_source : Mock ,
200+ apply_project_override : Mock ,
201+ vendor_rust : Mock ,
202+ tmp_path : pathlib .Path ,
203+ testdata_context : context .WorkContext ,
204+ ) -> None :
205+ """Verify vendor_rust is called with build_dir, not source_root_dir.
206+
207+ This tests the fix for issue #954: packages using build_dir option
208+ for alternative pyproject.toml location should vendor Rust code
209+ in the correct directory.
210+ """
211+ source_root_dir = tmp_path / "test_pkg-1.0.0"
212+ source_root_dir .mkdir ()
213+ req = Requirement ("test-pkg==1.0.0" )
214+ version = Version ("1.0.0" )
215+
216+ sources .prepare_new_source (
217+ ctx = testdata_context ,
218+ req = req ,
219+ source_root_dir = source_root_dir ,
220+ version = version ,
221+ )
222+
223+ vendor_rust .assert_called_once_with (req , source_root_dir / "python" )
224+
225+
226+ @patch ("fromager.sources.vendor_rust.vendor_rust" )
227+ @patch ("fromager.sources.pyproject.apply_project_override" )
228+ @patch ("fromager.sources.patch_source" )
229+ def test_prepare_new_source_uses_source_root_when_no_build_dir (
230+ patch_source : Mock ,
231+ apply_project_override : Mock ,
232+ vendor_rust : Mock ,
233+ tmp_path : pathlib .Path ,
234+ tmp_context : context .WorkContext ,
235+ ) -> None :
236+ """Verify vendor_rust uses source_root_dir when no build_dir is set."""
237+ source_root_dir = tmp_path / "some_pkg-1.0.0"
238+ source_root_dir .mkdir ()
239+ req = Requirement ("some-pkg==1.0.0" )
240+ version = Version ("1.0.0" )
241+
242+ sources .prepare_new_source (
243+ ctx = tmp_context ,
244+ req = req ,
245+ source_root_dir = source_root_dir ,
246+ version = version ,
247+ )
248+
249+ vendor_rust .assert_called_once_with (req , source_root_dir )
250+
251+
195252@pytest .mark .parametrize (
196253 "dist_name,version_string,sdist_filename,okay" ,
197254 [
0 commit comments