Repository navigation
feat: Allow build scripts to override package contents - #2476
Merged
wolfv merged 3 commits intoMay 8, 2026
Merged
Conversation
…ILD_PACKAGE_FILES Set RATTLER_BUILD_PACKAGE_FILES to a writable file path before running the build script. If the script writes any paths to that file, those paths are used as the package contents instead of the default new-files-in-$PREFIX diff. Each entry must be an absolute path under $PREFIX or a relative path that resolves against $PREFIX. The file is appendable across invocations, and falls back to the default behavior when empty or absent.
Rename the override file from `<build_dir>/package_files.txt` to `<build_dir>/.rattler-build-package-files` so that build scripts dropping files into $BUILD_DIR are extremely unlikely to clobber it by accident. Recipes only ever interact with the file through $RATTLER_BUILD_PACKAGE_FILES, so the rename is transparent to them.
- Docs: correct the description of the default file-discovery mechanism (conda-meta diff against $PREFIX, not a before/after snapshot of the build script). - Docs + code: keep applying `build.files` and `build.always_include_files` globs when the override list is used, so explicit selection composes with the usual filtering. - Docs + code: make paths that escape the prefix or do not exist a hard error instead of a silent warning. Add `PackagingError::PackageFileMissing` and `PackagingError::PackageFileOutsidePrefix`. - Drop the pre-existence stat in `read_package_files_list` — read the file directly and treat `NotFound` as the empty case. - Drop the pre-existence stat when clearing the override file before the build script runs — match on `ErrorKind::NotFound` instead. - Tests updated to cover the new signature and error semantics.
baszalmstra
force-pushed
the
claude/custom-package-files-option-DfYkn
branch
from
May 7, 2026 13:58
1845cca to
a5ac3c6
Compare
2 tasks done
wolfv
approved these changes
May 8, 2026
This was referenced Sep 30, 2026
This was referenced Oct 12, 2026
This was referenced Oct 27, 2026
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for build scripts to explicitly specify which files should be included in the final package by writing paths to a file pointed at by the
RATTLER_BUILD_PACKAGE_FILESenvironment variable. This provides an alternative to the default mechanism that determines package contents by diffing the prefix against conda-meta records.Key Changes
read_package_files_list()function: Reads and parses the package files override list from disk, handling missing files and empty lines gracefullyFiles::from_paths()method: Constructs aFilesstruct from an explicit list of paths, with validation that paths exist and stay within the prefix, plus support for applyingfilesandalways_includeglobs on topcollect_previous_files()helper: Extracted common logic for collecting previously installed files from conda-meta recordsRATTLER_BUILD_PACKAGE_FILESenvironment variable pointing to the override filePackageFileOutsidePrefixandPackageFileMissingerror variants for validationImplementation Details
.rattler-build-package-filesin the build directory to avoid accidental clobbering by build scripts$PREFIX) or relative (resolved against$PREFIX)echo path >> $RATTLER_BUILD_PACKAGE_FILESfilesandalways_includeglobs still apply on top of the explicit list, allowing combined filtering