@@ -374,14 +374,13 @@ def lock(
374374 generate_hashes = True ,
375375 python_version = None ,
376376 strip_extras = False ,
377- target_compatible_with = None ,
378- tags = ["manual" ],
379- visibility = None ):
377+ ** kwargs ):
380378 """Pin the requirements based on the src files.
381379
382380 This macro creates the following targets:
383381 - `name`: the target that creates the requirements.txt file in a build
384- action.
382+ action. This target will have `no-cache` and `requires-network` added
383+ to its tags.
385384 - `name.run`: a runnable target that can be used to pass extra parameters
386385 to the same command that would be run in the `name` action. This will
387386 update the source copy of the requirements file. You can customize the
@@ -394,6 +393,10 @@ def lock(
394393 args via command line, but you can use RBE to generate requirements
395394 (offload execution and run for different platforms)
396395
396+ :::{note}
397+ All of the targets have `manual` tags as locking results cannot be cached.
398+ :::
399+
397400 Args:
398401 name: {type}`str` The prefix of all targets created by this macro.
399402 srcs: {type}`list[Label]` The sources that will be used. Add all of the
@@ -416,11 +419,7 @@ def lock(
416419 python_version: {type}`str | None` the python_version to transition to
417420 when locking the requirements. Defaults to the default python version
418421 configured by the {obj}`python` module extension.
419- target_compatible_with: The `target_compatible_with` for the locking action.
420- tags: The common tags for all of the targets. This defaults to [`manual`].
421- Note, that the locking target also adds `requires-network` and
422- `no-cache` due to the nature of how `uv` works.
423- visibility: {attr}`list[str]` The visibility of the documented targets.
422+ **kwargs: common kwargs passed to rules.
424423 """
425424 update_target = "{}.update" .format (name )
426425 locker_target = "{}.run" .format (name )
@@ -429,10 +428,10 @@ def lock(
429428 # output file location in order to make `uv` not change the requirements if
430429 # we are just running the command.
431430 maybe_out = _maybe_file (out )
432- if target_compatible_with == None and not BZLMOD_ENABLED :
433- target_compatible_with = ["@platforms//:incompatible" ]
434- elif target_compatible_with == None :
435- target_compatible_with = []
431+
432+ tags = ["manual" ] + kwargs . pop ( "tags" , [])
433+ if not BZLMOD_ENABLED :
434+ kwargs [ " target_compatible_with" ] = ["@platforms//:incompatible" ]
436435
437436 # FIXME @aignas 2025-03-17: should we have one more target that transitions
438437 # the python_version to ensure that if somebody calls `bazel build
@@ -448,14 +447,13 @@ def lock(
448447 python_version = python_version ,
449448 srcs = srcs ,
450449 strip_extras = strip_extras ,
451- target_compatible_with = target_compatible_with ,
452450 update_target = update_target ,
453451 output = out ,
454452 tags = [
455453 "no-cache" ,
456454 "requires-network" ,
457455 ] + tags ,
458- visibility = visibility ,
456+ ** kwargs
459457 )
460458
461459 # A target for updating the in-tree version directly by skipping the in-action
@@ -469,7 +467,7 @@ def lock(
469467 "//conditions:default" : False ,
470468 }),
471469 tags = tags ,
472- visibility = visibility ,
470+ ** kwargs
473471 )
474472
475473 # FIXME @aignas 2025-03-20: is it possible to extend `py_binary` so that the
@@ -489,5 +487,5 @@ def lock(
489487 srcs = [template_target ],
490488 data = [name ] + ([maybe_out ] if maybe_out else []),
491489 tags = tags ,
492- visibility = visibility ,
490+ ** kwargs
493491 )
0 commit comments