runner.conda: Plug isolation leaks related to Python #311
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.
By default Python will search for modules in the user site directory, e.g. ~/.local/lib/python3.10/site-packages/. This is an isolation leak that can cause conflicts with our Conda runtime since its not containerized, and we observed such an issue during a workshop. Plug that leak by both disabling the searching of a user site directory entirely (the proximate issue) and pointing the whole Python user base directory to an alternate location (a preventative measure against other user base directory usages).
Similarly, PYTHONPATH and (probably more rarely) PYTHONHOME also have the potential to cause similar issues, so we now ensure they're unset when entering our Conda runtime. I reviewed other environment variables used by Python¹ and they seem reasonable to leave as-is (at least at this point). There are a few which could cause issues, but I expect they'd be limited to usage for debugging/troubleshooting/interactive use.
Resolves #309.
¹ https://docs.python.org/3/using/cmdline.html#environment-variables
Checklist