-
-
Notifications
You must be signed in to change notification settings - Fork 8
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 support for scie base value placeholders. #137
Conversation
Both the lift manifest `scie.lift.base` field and the `SCIE_BASE` env var now have their values expanded, accepting all placeholders except for the `{scie.lift}` which depends on the fully evaluated value of the scie base. In order to make OS-convention-friendly values feasible, a new `{scie.user.cache_dir=<fallback>}` placeholder is added that expands to the OS-appropriate user cache dir when defined and `<fallback>` when not.
Although this is not needed by Pants (yet), this was prompted by a-scie/lift#41. In the event Pants switches from a Mac (and Windows) unfriendly |
structure in the form of `{scie.user.cache_dir=<fallback>}`. Typically, this placeholder will expand | ||
to `~/Library/Caches` on macOS, `~\AppData\Local` on Windows and `~/.cache` on all other Unix | ||
systems unless over-ridden via OS-specific means or else unavailable for some reason, in which case | ||
the supplied `<fallback>` is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've been mis-reading this a few times.
unless over-ridden via OS-specific means or else unavailable for some reason, in which case the supplied
<fallback>
is used.
Using Linux as an example:
Without SCIE_BASE
we default to ~/.cache
, and if that is unavailable - we use the fallback
(if provided)?
With SCIE_BASE=/tmp/myfolder
, we attempt to use /tmp/myfolder
, and if that is unavailable, we use fallback
(if provided)?
Am I understanding this correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but your example is off. What you describe is true if and only if the custom base value (specified via config or env var) uses the {scie.user.cache_dir=<fallback>}
placeholder in it's value string somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the notes below:
{scie.user.cache_dir=<fallback>}
: The default user cache dir or<fallback>
if there is none.
So, this "fallback" is always provided, either as a default value or custom?
This was how I assumed it would work, but I think the wording above threw me for a loop maybe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You must fill in a value in place of fallback. See the test: #137 (comment)
If you don't supply a fallback that's a hard error. The dirs::cache_dir()
API is fallible. I'm not sure why, but that implies calculating a value can fail; this is exactly why I force you to supply a fallback value when using the placeholder.
let lift = Lift { | ||
name: "test".to_string(), | ||
description: None, | ||
base: Some(tempdir.path().to_path_buf()), | ||
base: Some( | ||
PathBuf::from("{scie.user.cache_dir={scie.env.USER_CACHE_DIR=/tmp/nce}}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sureshjoshi this is the new test section to expand and study to see the placeholder in use.
@sureshjoshi if you can supply alternate words for the doc portions of this change that make the new placeholder use more clear, I'd be happy to avoid confusing more people going forward. |
Nah, that's okay - I think I just have a fuzzy brain this morning. |
Alright, thanks @sureshjoshi. I'll land this and get a release out before I disappear until about next week this time. I'll see if I can get out a quick science release that upgrades the default scie-jump and has expanded docs for the |
Hrm, ok. I forgot science uses latest scie-jump by default unless you pin a version; so I won't be doing a new science release - it's good to go. |
Both the lift manifest
scie.lift.base
field and theSCIE_BASE
envvar now have their values expanded, accepting all placeholders except
for the
{scie.lift}
which depends on the fully evaluated value of thescie base.
In order to make OS-convention-friendly values feasible, a new
{scie.user.cache_dir=<fallback>}
placeholder is added that expands tothe OS-appropriate user cache dir when defined and
<fallback>
whennot.