Skip to content

Commit

Permalink
Merge pull request #4683 from lexming/soft-pythonpath
Browse files Browse the repository at this point in the history
avoid breaking Python environment by prepending CIME paths to PYTHONPATH
  • Loading branch information
jgfouca authored Sep 20, 2024
2 parents 64b2335 + 777cd60 commit 0cc20bf
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions CIME/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,10 @@ def run_cmd(
# or build a relative path and append `sys.path` to import
# `standard_script_setup`. Providing `PYTHONPATH` fixes protential
# broken paths in external python.
env.update(
{
"CIMEROOT": f"{get_cime_root()}",
"PYTHONPATH": f"{get_cime_root()}:{get_tools_path()}",
}
)
env_pythonpath = os.environ.get("PYTHONPATH", "").split(":")
cime_pythonpath = [f"{get_cime_root()}", f"{get_tools_path()}"] + env_pythonpath
env["PYTHONPATH"] = ":".join(filter(None, cime_pythonpath))
env["CIMEROOT"] = f"{get_cime_root()}"

if timeout:
with Timeout(timeout):
Expand Down

0 comments on commit 0cc20bf

Please sign in to comment.