@@ -334,15 +334,17 @@ def use_pytest(
334334 tool .remove_managed_files ()
335335
336336
337- def use_requirements_txt (* , remove : bool = False , how : bool = False ) -> None :
337+ def use_requirements_txt (
338+ * , remove : bool = False , how : bool = False , output_file : str = "requirements.txt"
339+ ) -> None :
338340 """Add and configure a requirements.txt file exported from the uv lockfile."""
339- tool = RequirementsTxtTool ()
341+ tool = RequirementsTxtTool (output_file = output_file )
340342
341343 if how :
342344 tool .print_how_to_use ()
343345 return
344346
345- path = usethis_config .cpd () / "requirements.txt"
347+ path = usethis_config .cpd () / output_file
346348
347349 if not remove :
348350 backend = get_backend ()
@@ -362,7 +364,7 @@ def use_requirements_txt(*, remove: bool = False, how: bool = False) -> None:
362364 tool .print_how_to_use ()
363365 return
364366
365- _generate_requirements_txt ()
367+ _generate_requirements_txt (output_file = output_file )
366368
367369 tool .print_how_to_use ()
368370 else :
@@ -373,36 +375,36 @@ def use_requirements_txt(*, remove: bool = False, how: bool = False) -> None:
373375 tool .remove_managed_files ()
374376
375377
376- def _generate_requirements_txt () -> None :
378+ def _generate_requirements_txt (* , output_file : str = "requirements.txt" ) -> None :
377379 backend = get_backend ()
378380 if backend is BackendEnum .uv :
379381 if not (usethis_config .cpd () / "pyproject.toml" ).exists ():
380- write_simple_requirements_txt ()
382+ write_simple_requirements_txt (output_file = output_file )
381383 elif not usethis_config .frozen :
382384 ensure_uv_lock ()
383- tick_print ("Writing 'requirements.txt '." )
385+ tick_print (f "Writing '{ output_file } '." )
384386 call_uv_subprocess (
385387 [
386388 "export" ,
387389 "--frozen" ,
388- "--output-file=requirements.txt " ,
390+ f "--output-file={ output_file } " ,
389391 ],
390392 change_toml = False ,
391393 )
392394 elif backend is BackendEnum .poetry :
393395 # Poetry uses poetry export for requirements.txt generation
394- write_simple_requirements_txt ()
396+ write_simple_requirements_txt (output_file = output_file )
395397 elif backend is BackendEnum .none :
396398 # Simply dump the dependencies list to requirements.txt
397399 if usethis_config .backend is BackendEnum .auto :
398400 info_print (
399- "Generating 'requirements.txt ' with un-pinned, abstract dependencies."
401+ f "Generating '{ output_file } ' with un-pinned, abstract dependencies."
400402 )
401403 info_print (
402404 "Consider installing 'uv' for pinned, cross-platform, full requirements files."
403405 )
404406
405- write_simple_requirements_txt ()
407+ write_simple_requirements_txt (output_file = output_file )
406408 else :
407409 assert_never (backend )
408410
0 commit comments