mctools / simplebuild

A very simple to use build system for projects with primarily C++/Python code, intended for usage by scientific developers without a strong SW-engineering background.
https://mctools.github.io/simplebuild/
Apache License 2.0
3 stars 1 forks source link

ensure PYTHONUNBUFFERED=1 #14

Open tkittel opened 1 year ago

tkittel commented 1 year ago

We already set PYTHONUNBUFFERED=1 when launching unit tests, but user output might also get scrambled if not set. Should we let simplebuild --env-setup handle this as well? Main issue is that:

eval "$(simplebuild --env-setup)"
export PYTHONUNBUFFERED=1
eval "$(simplebuild --env-unsetup)"

Might leave PYTHONUNBUFFERED=0 despite what the user asked for in line 2.

Another solution might simply be to set and never unset PYTHONUNBUFFERED=1.

Finally, we could read the spec carefully:

PYTHONUNBUFFERED
If this is set to a non-empty string it is equivalent to specifying the -u option.

Which gives us leeway to not only set the variable, but also add our signature. Perhaps we can store the old value of PYTHONUNBUFFERED, and set our own value to something recognisable (e.g. enabled-by-simplebuild). If the value remains at --env-unsetup time, we can restore the original value.