avoid breaking Python environment by prepending CIME paths to PYTHONPATH #4683
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.
CIME currently carries out a full reset of the
PYTHONPATH
environment variable. This is bad practice as other software in the user's session might rely on their paths being present inPYTHONPATH
to be usable.For instance, in HPC clusters it's very common to use modules to load software packages on-demand and those modules will add the paths of the loaded Python software to
PYTHONPATH
. In our case, we providelxml
as a module, which is one of the dependencies of CIME. Therefore, CIME is breaking itself by resettingPYTHONPATH
.This PR changes how CIME handles
PYTHONPATH
by prependingcime_root
andtools_path
toPYTHONPATH
instead of fully replacing it. This achieves the same goal of ensuring that external python can correctly import the CIME module, without breaking the rest of the Python ecosystem in the user's session.Test suite: n/a
Test baseline: n/a
Test namelist changes: n/a
Test status: n/a
Fixes: no open issue, but I can make a new one if you wish
User interface changes?: N
Update gh-pages html (Y/N)?: N