Skip to content
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

ensure undefined script_env variables are undefined in multi-output build environment #5322

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jameslamb
Copy link
Contributor

@jameslamb jameslamb commented Apr 30, 2024

Description

Fixes #5323

"Use Environment Variables" in the conda-build docs says the following about variables in build.script_env in recipes (my emphasis)

If a listed environment variable is missing from the environment seen by the conda-build process itself, a UserWarning is emitted during the build process and the variable remains undefined.

(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's build.script_env but not found in the environment where conda-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 ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

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 ''.

val... 

But passes on this branch.

@jameslamb jameslamb requested a review from a team as a code owner April 30, 2024 15:26
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Apr 30, 2024
Copy link

codspeed-hq bot commented Apr 30, 2024

CodSpeed Performance Report

Merging #5322 will not alter performance

Comparing jameslamb:fix/undefined-env-vars (5c84fac) with main (9c0ceec)

Summary

✅ 3 untouched benchmarks

@jameslamb
Copy link
Contributor Author

I've added an issue write-up (#5323), so this can be documented even if this specific PR isn't accepted.

Thanks for your time and consideration.

@jaimergp
Copy link
Contributor

Thanks for the write-up. I think this looks good to go, but I wasn't involved in the mentioned PR. Tagging @msarahan and @kenodegard to see what they think.

Copy link
Member

@mbargull mbargull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Status: Approved
Development

Successfully merging this pull request may close these issues.

Undefined environment variables are redefined in build script environment for multi-output builds
4 participants