-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add build.files
and negative globs to rattler-build
#819
Conversation
include_files
and negative globs to rattler-build
We should think about what an empty include and some "exclude" mean. Currently an empty We could change the behavior to mean that all paths are matched, and the exclude subtracts from that. Or at least we could offer a function that works this way. |
While implementing I came up with a few questions. Should only negative (exclude) globs be allowed? To filter from all paths? The implicit Maybe @carterbox has input here :) |
We currently don't handle the case with We might also want to refactor the |
The idea behind what I intended to implemented over in conda-build is that what you install with files include/exclude, is prefix (P) intersect installed-by-this-package (A) intersect include (I) subtract exclude (E). (P ∩ A ∩ I) - E. If any of P,A,I are an empty set, then the expression evaluates to an empty set. So no, there is not an implicit include: ["**/*"]. build:
include_files:
include: [] OR build:
include_files: [] Implies the empty set. A related question is whether it matters when you subtract the set E? It doesn't because all of the other operations are intersect.
Adding a special marker for "not" seems contrary to YAML, and would be more difficult to implement. So I prefer the use separate lists for include and exclude. Also, I believe that glob already gives special meaning to "!". |
Lemme know if you want me to try and review your actual implementation. I'm not too familiar with rust, but I could give it a try. For python we use the standard library set operations. Does rust have a set template class? |
@carterbox would love it if you can review the implementation - most of the magic is in the I might add some more tests with YAML so that we can easily put together some more test cases. The nice thing about this implementaiton is that it would work the same across all of the recipe (e.g. any place that accepts a list of globs now also accepts a Do you think we should error when we find a dictionary that contains only exclude then? |
@carterbox - i see that you commented in Since we don't have that issue, we are planning to also allow for a |
include_files
and negative globs to rattler-buildbuild.files
and negative globs to rattler-build
No. It's not an error to subtract from the empty set, just a silly thing to do. Errors are for when the user asks to do something is not possible / correct. For example, for i in range([]):
print(i) Looping over nothing does not raise an error.
Yes, I think the default behavior of conda-build for file lists is not good. Unfortunately, I don't have the time right now to think about what the default values for rattler should be for all the cases of users leaving keys undefined or empty. |
@carterbox the logic is now as follows:
Let me know if that looks bad for you! But essentially it will allow you to write something like:
to exclude everything except the header files, which is equivalent to:
Note: we do only consider new files for |
This adds the following: ```yaml build: files: # select files to include based on a glob expression - foo/* ``` It also extends the `glob` definition (in `rattler-build` that's the `GlobVec` type). You can use either a single glob, a list of globs (treated as `include` globs) or a map with `include` and `exclude` globs. ```yaml files: foo/* # or files: - foo/* # or files: include: - foo/* exclude: - *.txt ``` All three forms are valid in PR prefix-dev/rattler-build#819 Note: CEP has to be updated as well.
This changes all places where lists of globs are accepted to accept either a list of globs or a map with
include / exclude
. It also adds a newinclude_files
key to thebuild
map that allows to filter files that should be part of the package.It looks like this:
The
include
operation is done before the exclude operation, meaning that the list of files is first filtered by theinclude
globs, and then the remaining files are filtered by theexclude
globs.There are a few open questions:
exclude
globs work when there are noinclude
globs? Meaning, we assume that all files are included by default (ie. implicitinclude: ["**/*"]
)?include / exclude
map? Or should we have a list, where one item can beexclude: [...]
? Or should we mark the negative globs, for example with~ lib/*.exe
or^ lib/*.exe
? The!
operator doesn't work as it denotes something in YAML.TODO