Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions conda_recipe_v2_schema/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ class ScriptEnv(StrictBaseModel):
)


class PostProcess(StrictBaseModel):
files: list[NonEmptyStr] = Field(
...,
description="List of glob patterns selecting files to process. Files must be valid UTF-8 text.",
)
regex: NonEmptyStr = Field(
...,
description="Regular expression pattern to match (uses Rust `regex` crate semantics).",
)
replacement: str = Field(
...,
description="Replacement string applied using `replace_all` behavior.",
)


class Build(StrictBaseModel):
number: UnsignedInt | JinjaExpr | None = Field(
0,
Expand Down Expand Up @@ -251,6 +266,11 @@ class Build(StrictBaseModel):
None, description="Glob patterns to include or exclude files from the package."
)

post_process: list[PostProcess] | None = Field(
None,
description="A list of post-processing steps. Each entry applies a regex replacement on the selected files. Files must be valid UTF-8 text. Regex uses Rust `regex` crate semantics and `replace_all` behavior.",
)


class BaseScript(StrictBaseModel):
interpreter: NonEmptyStr | None = Field(
Expand Down
23 changes: 23 additions & 0 deletions examples/valid/post-process/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# yaml-language-server: $schema=../../../schema.json

# Example recipe demonstrating the build.post_process feature.
# post_process applies regex replacements on files in the package
# after the build step. Files must be valid UTF-8 text.
# Regex uses Rust `regex` crate semantics with `replace_all` behavior.

package:
name: post-process-example
version: "1.0.0"

build:
number: 0
post_process:
- files:
- "bin/*"
regex: "/old/path"
replacement: "/new/path"
- files:
- "**/*.cmake"
- "**/*.pc"
regex: "/home/builder"
replacement: "$PREFIX"
64 changes: 64 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,22 @@
"default": null,
"description": "Glob patterns to include or exclude files from the package.",
"title": "Files"
},
"post_process": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/PostProcess"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A list of post-processing steps. Each entry applies a regex replacement on the selected files. Files must be valid UTF-8 text. Regex uses Rust `regex` crate semantics and `replace_all` behavior.",
"title": "Post Process"
}
},
"title": "Build",
Expand Down Expand Up @@ -2960,6 +2976,22 @@
"description": "Glob patterns to include or exclude files from the package.",
"title": "Files"
},
"post_process": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/PostProcess"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A list of post-processing steps. Each entry applies a regex replacement on the selected files. Files must be valid UTF-8 text. Regex uses Rust `regex` crate semantics and `replace_all` behavior.",
"title": "Post Process"
},
"cache_only": {
"default": false,
"deprecated": true,
Expand Down Expand Up @@ -3256,6 +3288,38 @@
"title": "PerlTestElementInner",
"type": "object"
},
"PostProcess": {
"additionalProperties": false,
"properties": {
"files": {
"description": "List of glob patterns selecting files to process. Files must be valid UTF-8 text.",
"items": {
"minLength": 1,
"type": "string"
},
"title": "Files",
"type": "array"
},
"regex": {
"description": "Regular expression pattern to match (uses Rust `regex` crate semantics).",
"minLength": 1,
"title": "Regex",
"type": "string"
},
"replacement": {
"description": "Replacement string applied using `replace_all` behavior.",
"title": "Replacement",
"type": "string"
}
},
"required": [
"files",
"regex",
"replacement"
],
"title": "PostProcess",
"type": "object"
},
"PrefixDetection": {
"additionalProperties": false,
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@pytest.fixture(
scope="module",
params=["mamba", "xtensor", "single-output", "zlib", "staging"],
params=["mamba", "xtensor", "single-output", "zlib", "staging", "post-process"],
)
def valid_recipe(request) -> str:
recipe_name = request.param
Expand Down