Open bfloch opened 5 years ago
EDIT: Wrote a lightweight factory / not type. See post below.
I really like the idea of the platform dependent dictionary. One problem with this is that if the original value is a dict it gets hard to identify as such. It is also hard to verify the schema. I believe there would be value in having this expanded as a feature for any config in rezconfig. I suggest to implement this separately with a special type that behaves like a dict but is explicit.
For example:
from rez.utils.config import PlatformDependent
default_shell = PlatformDependend({
"windows": "pwsh",
"*": None # Default
})
If all of you agree I move this in a separate issue to discuss schema handling etc.
Deduplication is shell dependent. As a proof of concept we already have this in PATHEXT
on the windows platforms. It looks something like this:
https://github.com/nerdvegas/rez/pull/698/commits/a3f21db6f308d0130782960a2657dabf3f322d3c
The drawback is that it is evaluating logic and you would do this on each append. An alternative would be to do a single final deduplication pass. I haven't done this on cmd but I guess it would be possible via techniques like:
for /f "tokens=2 delims=:" %%A in ("%%f") Do @Echo %%A
https://superuser.com/questions/1407317/how-to-split-variable-by-colon-in-batch
The idea is that you set it per variable:
"PATH": {
"deduplicate": True,
# ...
},
I am not sure it is necessary to distinguish between deduplication that keeps the earliest, initial (hard as final op) or latest duplicate. I would just go with the earliest for now. Is this sufficient? The final deduplication approach is a bit different when the variable is being referenced along the way, but I guess it is acceptable. Many options. Curious for feedback.
The platform dependent configuration was way simpler and cleaner to implement then I thought. Please checkout: https://github.com/nerdvegas/rez/pull/739
EDIT: Updated to sample with #739 in place
I think this is good.
One thing I'd say though is that I found the "parent_variables" terminology confusing. I think it's because 'append/prepend' s being used to mean slightly different things - ie, append as in add a path to the end of a set of paths; but also, append as in, append the SET of pre-existing paths to whatever paths rez constructs.
What might be better is "modify_mode" instead (which sits alongside modify_op). Values would be:
Similarly, I think changing all the terminology like "append_all" etc to "after_all", "before_parent" etc would help - it's more intuitive because it describes where an item should appear in a list. Because append/prepend are verbs, it's a bit confusing in the context of multiple different sets of paths (if that makes sense).
But these are just terminology quibbles, overall I think the structure and approach is fine.
RE deduplication: I would dedup along the way, better that the var value be as expected at all times. I would agree though that keeping earliest value is probably good enough, I really can't think of a case where you wouldn't want that.
One thing to consider is what the "parent" value of a var really is. IMO it would be the pre-rez value of the var - but you may have nested rez-envs too, that will have to be taken into account (in that case, I think it should still be the first pre-rez value that is used).
A
(Originated from #707)
Settings and Ops
This is a rather complex topic since we want to support so many use cases so I'll build up to the suggestion based on every possible use case imaginable. It also gives us opportunity to migrate existing settings in a generic configuration.
I don't want to jump into implementation details yet (hope this is doable at all :) ), but let's see if we can come up with use cases best demonstrated via an sample.
References
703
698
661
(more ?)
Use cases
(cases handled by the sample are crossed)
all_*_variables
Sample
(Note: This is a completely artificial example to showcase many possible use cases)
Naming, features and details are like always up for discussion. Let me know if I missed anything.