Skip to content

Commit

Permalink
typecast arg of "which" to str for python 3.9 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
martclanor committed Jan 9, 2025
1 parent f59496d commit 86be08a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions flopy/mbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,18 @@ def _resolve(exe_name, checked=set()):
checked.add(exe_name)

# exe_name is found (not None), ensure absolute path is returned
if exe := which(exe_name):
return which(Path(exe).resolve())
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(Path(exe_name).expanduser().resolve())):
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(Path(exe_name).resolve(), mode=0)
exe := which(str(Path(exe_name).resolve()), mode=0)
): # mode=0 effectively allows which() to find exe without suffix in windows
return exe

Expand Down

0 comments on commit 86be08a

Please sign in to comment.