ensure undefined script_env variables are undefined in multi-output build environment #5322
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.
Description
Fixes #5323
"Use Environment Variables" in the
conda-build
docs says the following about variables inbuild.script_env
in recipes (my emphasis)(link)
As of #5105,
conda-build
does not behave that way for multi-output recipes. As of that PR, any variable mentioned in the recipe'sbuild.script_env
but not found in the environment whereconda-build
is called from will be set to the empty string''
in the build script environment.This PR proposes ensuring that such variables remain unset in the build script environment.
Thanks for your time and consideration.
Benefits of these changes
Removes a source of behavioral difference between top-level and multi-output builds.
Reduces a source of friction when using build scripts that are sensitive to the difference between environment variables being unset and being set to an empty string. (for example, with optional AWS credentials for
sccache
like this).Checklist - did you ...
news
directory (using the template) for the next release's release notes?How I tested this
The unit test I've added here fails on
main
.git checkout main -- conda_build/build.py pytest tests/test_subpackages.py::test_build_script_does_not_set_env_from_script_env_if_missing # Failed: DID NOT RAISE <class 'subprocess.CalledProcessError'>
And prints this message from the build script in stdout of the build process, showing that the unset environment variable is set to
''
.But passes on this branch.