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

runner.conda: Plug isolation leaks related to Python #311

Merged
merged 2 commits into from
Sep 20, 2023

Conversation

tsibley
Copy link
Member

@tsibley tsibley commented Sep 15, 2023

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

  • Checks pass

@tsibley tsibley requested a review from a team September 15, 2023 19:21
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>
@tsibley tsibley force-pushed the trs/conda/plug-python-isolation-leaks branch from 0d10f0e to a9e6c34 Compare September 19, 2023 23:03
@tsibley tsibley merged commit 0da8cbb into master Sep 20, 2023
41 checks passed
@tsibley tsibley deleted the trs/conda/plug-python-isolation-leaks branch September 20, 2023 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Python user site directory leaks into Conda runtime
2 participants