Skip to content

Commit 2bba6f3

Browse files
authored
Backup PYTHONPATH for use with run_external (#157)
1 parent 254ffbf commit 2bba6f3

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/subscript/runrms/runrms.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ def __init__(self):
218218
if "PYTHONPATH" in os.environ:
219219
self.oldpythonpath = os.environ["PYTHONPATH"]
220220

221+
# Set environment variables for use by `run_external`
222+
# from equinor/equilibrium:
223+
if "PYTHONPATH" in os.environ:
224+
os.environ["_PRE_RMS_PYTHONPATH"] = os.environ["PYTHONPATH"]
225+
else:
226+
os.environ["_PRE_RMS_PYTHONPATH"] = ""
227+
os.environ["_PRE_RMS_BACKUP"] = "1"
228+
221229
print(
222230
_BColors.BOLD,
223231
"\nRunning <{0}>. Type <{0} -h> for help\n".format(THISSCRIPT),
@@ -500,7 +508,7 @@ def get_pythonpath(self):
500508
)
501509

502510
def launch_rms(self, empty=False):
503-
"""Lauch RMS with correct pythonpath"""
511+
"""Launch RMS with correct pythonpath"""
504512

505513
if self.exe is None:
506514
self.exe = "rms -v " + self.version_requested

tests/test_runrms.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ def test_do_parse_args(tmpdir):
4141
assert "dryrun=True" in str(runner.args)
4242

4343

44+
def test_backuppythonpath():
45+
rr.RunRMS()
46+
assert "_PRE_RMS_BACKUP" in os.environ
47+
assert "_PRE_RMS_PYTHONPATH" in os.environ
48+
49+
4450
@pytest.mark.integration
4551
def test_integration():
4652
"""Test that the endpoint is installed"""

0 commit comments

Comments
 (0)