-
Notifications
You must be signed in to change notification settings - Fork 168
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
Added support for script_env_variables
#718
Conversation
We require contributors to sign our Contributor License Agreement and we don't have one on file for @jlstevens. In order for us to review and merge your code, please e-sign the Contributor License Agreement PDF. We then need to manually verify your signature, merge the PR (conda/infrastructure#822), and ping the bot to refresh the PR. |
Thanks for bringing this up in such an accommodating way! I am not opposed to the idea, but:
In general I wonder if this is better solved with an example that documents how to run a pre-processing script to template your pre and post scripts on your own, without direct support in |
Glad to hear it!
Agreed. My last commit adds support to Windows.
Yes, we will need clear documentation. I think it would be fine to only support simple literals initially and apply strict validation of the construct.yaml.
Got any suggestions? Would
While I agree that would be useful for even more complex use cases, I think the idea of passing in additional environment variables into the scripts improves on a fairly simple and clearly defined interface, especially as constructor is already defining environment variables for consumption by these scripts. I think your suggestion is a good one but orthogonal to what is proposed in this PR. |
@jaimergp Thanks for the review! I am happy with all your suggestions. Would you like me to apply them? |
Co-authored-by: jaimergp <[email protected]>
I went ahead and applied all your suggestions. If this seems good to you, I'll go ahead and start tackling the docs. |
Let's go with The tests are passing and sufficient, so yea let's go and document this nicely, emphasizing on the fact that only literals are supported and that escaping, if needed, it's on the user (e.g. spaces require quoting à la `var: '"value with spaces"'), while accounting for YAML itself. That might be a bit annoying though, so we can also document that we always quote the value (update needed in the code), so inner quotes need to be escaped. I think the latter is more reasonable (because spaces would be more common than quotes in a value, I hope). So, questions to tackle in the docs, depending on what we do in the code. On Unix, I'd say we should always quote the value because not doing it causes more trouble than it's worth. However:
WDYT? |
Agreed. Implemented in 7d43220
I agree. Single quoting seems safer and I think will be appropriate for the vast majority of use-cases. Once you get your values into your pre-/post-install scripts you can do your string interpolation in there. On Unix I guess this just means wrapping the value from the dictionary in |
I think we are fine with the current code. The env var is being set directly via Windows APIs, not CMD. So we don't need to do anything else (we are already using |
extra_env_variables
script_env_variables
I've updated the Now I will test this out on Windows with the |
In case you are doing this manually, the workflow is to edit |
Getting special characters to work in the Windows environment variable seems to be trickier:
So until I figure it out, my Windows test string is the same as the Unix one but without quotes which I haven't manage to handle. I am not sure how much effort should be spent on allowing quotes on Windows: I would be tempted to simply document that they are not supported (or I could apply some validation in the code...but I can't for |
@conda-bot check |
@jaimergp All checks are now green! Ready for review. |
Thanks for reviewing @dbast! |
Adds support for an
extra_env_variables
key in theconstruct.yaml
e.g.:This makes these environment variables available to the
pre_install
andpost_install
scripts.Motivation: This mechanism makes it much easier to template installers that use
pre_install
andpost_install
scripts, allowing those scripts to stay generic and unchanged while making the templated changes clear in theconstruct.yaml
in an easy-to-read, declarative form.Right now only Unix .sh installers are supported in this PR. I wanted to see whether to constructor maintainers are open to this addition before implementing support for other platforms.
The only open question I have right now is whether there is a use-case to allow custom overrides of the pre-defined variables (i.e.
$INSTALLER_NAME
,$INSTALLER_VER
,$INSTALLER_PLAT
). My instinct is that there is no good reason to allow this so this PR ensures that custom extra variable definitions cannot override these definitions.news
directory (using the template) for the next release's release notes?