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

avoid breaking Python environment by prepending CIME paths to PYTHONPATH #4683

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

lexming
Copy link
Contributor

@lexming lexming commented Sep 20, 2024

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 in PYTHONPATH 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 provide lxml as a module, which is one of the dependencies of CIME. Therefore, CIME is breaking itself by resetting PYTHONPATH .

This PR changes how CIME handles PYTHONPATH by prepending cime_root and tools_path to PYTHONPATH 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

lexming added a commit to vub-hpc/cesm-config that referenced this pull request Sep 20, 2024
wpoely86 added a commit to vub-hpc/cesm-config that referenced this pull request Sep 20, 2024
Copy link
Contributor

@jedwards4b jedwards4b left a comment

Choose a reason for hiding this comment

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

LGTM - Thanks!

@jgfouca jgfouca merged commit 0cc20bf into ESMCI:master Sep 20, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants