Skip to content

Commit 665e649

Browse files
committed
feat: add staging outputs and deprecate cache
Replace the top-level `cache:` section in multi-output recipes with first-class staging outputs in the `outputs:` list, matching the rattler-build schema change.
1 parent be8300e commit 665e649

4 files changed

Lines changed: 497 additions & 3 deletions

File tree

conda_recipe_v2_schema/model.py

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,20 @@ class IgnoreRunExports(StrictBaseModel):
379379
)
380380

381381

382+
class StagingRequirements(StrictBaseModel):
383+
build: ConditionalList[MatchSpec] | None = Field(
384+
None,
385+
description="Dependencies to install on the build platform architecture for the staging build.",
386+
)
387+
host: ConditionalList[MatchSpec] | None = Field(
388+
None,
389+
description="Dependencies to install on the host platform architecture for the staging build.",
390+
)
391+
ignore_run_exports: IgnoreRunExports | None = Field(
392+
None, description="Ignore run-exports by name or from certain packages"
393+
)
394+
395+
382396
class LinkOptions(StrictBaseModel):
383397
post_link_script: NonEmptyStr | None = Field(
384398
None,
@@ -604,19 +618,64 @@ class About(StrictBaseModel):
604618
class OutputBuild(Build):
605619
cache_only: bool = Field(
606620
default=False,
621+
deprecated="Use staging outputs instead.",
607622
description="Do not output a package but use this output as an input to others.",
608623
)
609624
cache_from: ConditionalList[NonEmptyStr] | None = Field(
610625
None,
626+
deprecated="Use staging outputs instead.",
611627
description="Take the output of the specified outputs and copy them in the working directory.",
612628
)
613629

614630

631+
class StagingBuild(StrictBaseModel):
632+
script: str | Script | ConditionalList[NonEmptyStr] | None = Field(
633+
None,
634+
description="The script to execute to invoke the staging build.",
635+
)
636+
637+
638+
class StagingMeta(StrictBaseModel):
639+
name: NonEmptyStr = Field(..., description="Unique name for this staging cache.")
640+
641+
642+
class StagingOutput(StrictBaseModel):
643+
staging: StagingMeta = Field(
644+
..., description="Marks this output as a staging output with the given name."
645+
)
646+
source: ConditionalList[Source] | None = Field(
647+
None, description="The source items to be downloaded and used for the staging build."
648+
)
649+
requirements: StagingRequirements | None = Field(
650+
None, description="The dependencies needed for the staging build."
651+
)
652+
build: StagingBuild | None = Field(
653+
None, description="Build configuration for the staging output."
654+
)
655+
656+
657+
class CacheInherit(StrictBaseModel):
658+
from_: NonEmptyStr = Field(
659+
...,
660+
alias="from",
661+
description="Name of the staging cache to inherit from.",
662+
)
663+
run_exports: bool = Field(
664+
default=True,
665+
description="Whether to inherit run_exports from the staging cache.",
666+
)
667+
668+
615669
class Output(StrictBaseModel):
616670
package: ComplexPackage | None = Field(
617671
None, description="The package name and version, this overwrites any top-level fields."
618672
)
619673

674+
inherit: NonEmptyStr | CacheInherit | None = Field(
675+
None,
676+
description="Name of the staging cache to inherit from, or an object with `from` and `run_exports` options.",
677+
)
678+
620679
source: ConditionalList[Source] | None = Field(
621680
None, description="The source items to be downloaded and used for the build."
622681
)
@@ -692,10 +751,12 @@ class ComplexRecipe(BaseRecipe):
692751
recipe: ComplexPackage | None = Field(None, description="The package version.")
693752

694753
cache: Cache | None = Field(
695-
None, description="The cache build that can be used as a common build step for all output."
754+
None,
755+
deprecated="Use staging outputs instead.",
756+
description="The cache build that can be used as a common build step for all output.",
696757
)
697758

698-
outputs: ConditionalList[Output] = Field(
759+
outputs: ConditionalList[Output | StagingOutput] = Field(
699760
..., description="A list of outputs that are generated for this recipe."
700761
)
701762

examples/valid/staging/recipe.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# yaml-language-server: $schema=../../../schema.json
2+
3+
schema_version: 1
4+
5+
context:
6+
version: "1.0.0"
7+
8+
recipe:
9+
name: my-package
10+
version: ${{ version }}
11+
12+
source:
13+
url: https://example.com/source-${{ version }}.tar.gz
14+
sha256: 1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
15+
16+
outputs:
17+
- staging:
18+
name: my-staging-cache
19+
source:
20+
- url: https://example.com/extra-source.tar.gz
21+
sha256: abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890
22+
requirements:
23+
build:
24+
- ${{ compiler('c') }}
25+
- cmake
26+
- ninja
27+
host:
28+
- zlib
29+
build:
30+
script: build_shared.sh
31+
32+
- package:
33+
name: my-lib
34+
version: ${{ version }}
35+
inherit: my-staging-cache
36+
build:
37+
script: install_lib.sh
38+
requirements:
39+
host:
40+
- zlib
41+
run:
42+
- zlib
43+
44+
- package:
45+
name: my-tools
46+
version: ${{ version }}
47+
inherit:
48+
from: my-staging-cache
49+
run_exports: false
50+
build:
51+
script: install_tools.sh
52+
requirements:
53+
host:
54+
- zlib
55+
run:
56+
- zlib
57+
- ${{ pin_subpackage('my-lib', exact=True) }}

0 commit comments

Comments
 (0)