@@ -374,14 +374,13 @@ def lock(
374
374
generate_hashes = True ,
375
375
python_version = None ,
376
376
strip_extras = False ,
377
- target_compatible_with = None ,
378
- tags = ["manual" ],
379
- visibility = None ):
377
+ ** kwargs ):
380
378
"""Pin the requirements based on the src files.
381
379
382
380
This macro creates the following targets:
383
381
- `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.
385
384
- `name.run`: a runnable target that can be used to pass extra parameters
386
385
to the same command that would be run in the `name` action. This will
387
386
update the source copy of the requirements file. You can customize the
@@ -394,6 +393,10 @@ def lock(
394
393
args via command line, but you can use RBE to generate requirements
395
394
(offload execution and run for different platforms)
396
395
396
+ :::{note}
397
+ All of the targets have `manual` tags as locking results cannot be cached.
398
+ :::
399
+
397
400
Args:
398
401
name: {type}`str` The prefix of all targets created by this macro.
399
402
srcs: {type}`list[Label]` The sources that will be used. Add all of the
@@ -416,11 +419,7 @@ def lock(
416
419
python_version: {type}`str | None` the python_version to transition to
417
420
when locking the requirements. Defaults to the default python version
418
421
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.
424
423
"""
425
424
update_target = "{}.update" .format (name )
426
425
locker_target = "{}.run" .format (name )
@@ -429,10 +428,10 @@ def lock(
429
428
# output file location in order to make `uv` not change the requirements if
430
429
# we are just running the command.
431
430
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" ]
436
435
437
436
# FIXME @aignas 2025-03-17: should we have one more target that transitions
438
437
# the python_version to ensure that if somebody calls `bazel build
@@ -448,14 +447,13 @@ def lock(
448
447
python_version = python_version ,
449
448
srcs = srcs ,
450
449
strip_extras = strip_extras ,
451
- target_compatible_with = target_compatible_with ,
452
450
update_target = update_target ,
453
451
output = out ,
454
452
tags = [
455
453
"no-cache" ,
456
454
"requires-network" ,
457
455
] + tags ,
458
- visibility = visibility ,
456
+ ** kwargs
459
457
)
460
458
461
459
# A target for updating the in-tree version directly by skipping the in-action
@@ -469,7 +467,7 @@ def lock(
469
467
"//conditions:default" : False ,
470
468
}),
471
469
tags = tags ,
472
- visibility = visibility ,
470
+ ** kwargs
473
471
)
474
472
475
473
# FIXME @aignas 2025-03-20: is it possible to extend `py_binary` so that the
@@ -489,5 +487,5 @@ def lock(
489
487
srcs = [template_target ],
490
488
data = [name ] + ([maybe_out ] if maybe_out else []),
491
489
tags = tags ,
492
- visibility = visibility ,
490
+ ** kwargs
493
491
)
0 commit comments