@@ -65,7 +65,6 @@ _RunLockInfo = provider(
6565def _lock_impl (ctx ):
6666 args = ctx .attr .args
6767 srcs = ctx .files .srcs
68- existing_output = ctx .files .existing_output
6968 output = ctx .actions .declare_file (ctx .label .name + ".out" )
7069
7170 toolchain_info = ctx .toolchains [UV_TOOLCHAIN_TYPE ]
@@ -114,10 +113,11 @@ def _lock_impl(ctx):
114113 lock_args .add ("--output-file" , output )
115114
116115 progress_message = "Creating a requirements.txt with uv: //{}:{}" .format (ctx .label .package , ctx .label .name )
117- if existing_output :
116+ if ctx . files . existing_output :
118117 ctx .actions .run_shell (
119- command = "cp {src} {dst} && \" $@\" " .format (
120- src = existing_output .path ,
118+ command = "{copy} {src} {dst} && \" $@\" " .format (
119+ copy = ctx .attr .copy_cmd ,
120+ src = ctx .files .existing_output [0 ].path ,
121121 dst = output .path ,
122122 ),
123123 mnemonic = "PyRequirementsLockUv" ,
@@ -130,10 +130,7 @@ def _lock_impl(ctx):
130130 )
131131 else :
132132 ctx .actions .run_shell (
133- command = "\" $@\" " .format (
134- src = ctx .files .existing_output [0 ].path ,
135- dst = output .path ,
136- ),
133+ command = "\" $@\" " ,
137134 mnemonic = "PyRequirementsLockUv" ,
138135 inputs = srcs ,
139136 outputs = [output ],
@@ -171,6 +168,9 @@ _lock = rule(
171168 allow_files = True ,
172169 doc = "Public, see the docs in the macro." ,
173170 ),
171+ "copy_cmd" : attr .string (
172+ mandatory = True ,
173+ ),
174174 "env" : attr .string_dict (
175175 doc = "Public, see the docs in the macro." ,
176176 ),
@@ -378,6 +378,11 @@ def lock(
378378 strip_extras = strip_extras ,
379379 target_compatible_with = target_compatible_with ,
380380 update_target = update_target ,
381+ # TODO @aignas 2025-03-17: consider using python to copy files?
382+ copy_cmd = select ({
383+ "@platforms//os:windows" : "copy /v" ,
384+ "//conditions:default" : "cp -v" ,
385+ }),
381386 tags = [
382387 "local" ,
383388 "manual" ,
0 commit comments