From 391c4d8f3246c012d3d347c0a88649961f9016b2 Mon Sep 17 00:00:00 2001 From: martclanor Date: Thu, 9 Jan 2025 15:11:06 +0100 Subject: [PATCH] expanduser for all relative paths to simplify --- flopy/mbase.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/flopy/mbase.py b/flopy/mbase.py index 5d9455724..02c6ad2dd 100644 --- a/flopy/mbase.py +++ b/flopy/mbase.py @@ -74,16 +74,12 @@ def _resolve(exe_name, checked=set()): if exe := which(str(exe_name)): return which(str(Path(exe).resolve())) - # exe_name has "~", expand first before returning absolute path - if "~" in exe_name and ( - exe := which(str(Path(exe_name).expanduser().resolve())) - ): - return exe - # exe_name is relative path if not Path(exe_name).is_absolute() and ( - exe := which(str(Path(exe_name).resolve()), mode=0) - ): # mode=0 effectively allows which() to find exe without suffix in windows + exe := which(str(Path(exe_name).expanduser().resolve()), mode=0) + ): + # expanduser() in case of ~ in path + # mode=0 effectively allows which() to find exe without suffix in windows return exe # try adding/removing .exe suffix